n++ < 10 syntax error??

Paul Rubin phr-n2002a at nightsong.com
Sun Jan 13 11:46:18 EST 2002


rihad <rihad at mail.ru> writes:
> Hi there, continuing with my foray into the innards of Python, I found
> myself stumbled over this:
> 
> n = 0
> while n++ < 10:
>   pass
> 
> Gives a syntax error. Changing n++ to ++n compiles fine.... What the
> hell is going on???
> 
> (P.S. I know I can use the "for n in range(10)" idiom, but what's
> wrong with n++?)

Python doesn't have the ++ autoincrement operator.  + is a unary operator
on a numeric arg, that does nothing.  ++n is the same as n.  



More information about the Python-list mailing list