On Sun, Aug 12, 2012 at 8:30 AM, John Ladasky
<john_lada...@sbcglobal.net> wrote:
> In [7]: 1 + not(len(L) % 2)
> ------------------------------------------------------------
>    File "<ipython console>", line 1
>      1 + not(len(L) % 2)
>            ^
> SyntaxError: invalid syntax

This appears to be a limitation of the parser; it's trying to
interpret "not" as a binary operator.

1 + (not(len(L) % 2))

Works just fine with parentheses to enforce the correct interpretation.

This also works in Python 3.2, fwiw (except that you need
list(range(5)) to create the sample list).

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to