inline comparison

Tim Roberts timr at probo.com
Sun Mar 20 00:45:12 EST 2005


sam <sam.wun at authtec.com> wrote:

>Hi,
>
>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? I don't want to break down this 
>comparison in two steps.

Sorry, you have to.  Assignment statements are not expressions in Python.  

    m = self.macro_parser.match(d)
    if m:
        xxx

You know the outer parentheses are not necessary, right?
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list