Jython – SyntaxError: mismatched input ‘,’ expecting COLON

jython

I have this code that I wrote in python:

from Purchase import Transaction
from Purchase import MoneyStatement

if __name__ == '__main__':
    p= {Transaction('costco','me', 45, "AmEx"),Transaction('costco','me', 45, "AmEx")}
    ms= MoneyStatement('AmEx 10-19-2012', p)
    print(ms)

And it works in python, but when I try to run it in jython it gives me this error:

p= {Transaction('costco','me', 45, "AmEx"),Transaction('costco','me', 45, "AmEx")}

                               ^

SyntaxError: mismatched input ',' expecting COLON

Best Answer

It works in Python 2.7 and 3. It does not work in pre-2.7, which is what Jython (at least the current release, I vaguely recall 2.7 compatibility being worked on) supports. There is no set literal syntax in those versions. Use what you'd use on pre-2.7 CPython too: set([item1, item2, ...])

Related Topic