Suggestion for "syntax error": ++i, --i

Steven Bethard steven.bethard at gmail.com
Mon Dec 13 12:22:10 EST 2004


Petr Prikryl wrote:
> Summary: In my opinion, the C-like prefix
> increment and decrement operators (++i and --i)
> should be marked as "syntax error".

This would give some weird assymetry:

 >>> i = 1
 >>> ++i
Traceback (  File "<interactive input>", line 1
     ++i
       ^
SyntaxError: invalid syntax
 >>> --i
Traceback (  File "<interactive input>", line 1
     --i
       ^
SyntaxError: invalid syntax
 >>> +-i
-1
 >>> -+i
-1
 >>>

Of course, anyone who writes +-i or -+i should probably be shot anyway. 
;)  I'm -0 on this.

Steve



More information about the Python-list mailing list