peter at engcorp.com
Sun Mar 20 04:38:58 CET 2005
> I got the the following syntax error in comparison:
> File "/usr/local/work/myparser.py", line 85
> if ( (m=self.macro_parser.match (d)) != None ):
> SyntaxError: invalid syntax
> How can I get around wtih this?
Break the comparison into two steps.
> I don't want to break down this comparison in two steps.
Why not? Assignments are statements in Python, and
you can't have a statement inside an expression like
you are trying to do. C can do it, and many other
languages, but not all, and not Python. There are
alternatives involving creating your own class, but
why bother? Just split the code...
More information about the Python-list