n++ < 10 syntax error??
Chris Liechti
cliechti at gmx.net
Sun Jan 13 11:51:57 EST 2002
More information about the Python-list mailing list
Sun Jan 13 11:51:57 EST 2002
- Previous message (by thread): n++ < 10 syntax error??
- Next message (by thread): n++ < 10 syntax error??
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
rihad <rihad at mail.ru> wrote in news:h7d34ucusarslbdqfhiu2bvsph2lg9bf5t at 4ax.com: > 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++?) there is no pre/post increment in python ++n applies the unary operator + (__pos__) twice... newer versions of python support += etc. n=0 while n<10: n+=1 i still prefer the for loop with range. -- Chris <cliechti at gmx.net>
- Previous message (by thread): n++ < 10 syntax error??
- Next message (by thread): n++ < 10 syntax error??
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list