n++ < 10 syntax error??
Pekka Pessi
Pekka.Pessi at nokia.com
Sun Jan 13 11:48:25 EST 2002
In message <h7d34ucusarslbdqfhiu2bvsph2lg9bf5t at 4ax.com> rihad <rihad at mail.ru> writes:
>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++?)
There is no postincrement operator in Python. There is no
preincrement either, but ++n parses as + + n (which equals to
- - n):
>>> n = 1
>>> ++n
1
>>> ++n == --n
1
Pekka
More information about the Python-list
mailing list