[Python-Dev] ++x oddnes

Guido van Rossum guido@python.org
Fri, 10 Aug 2001 11:23:37 -0400


> Sorry if this is old news.  I don't remember anybody reporting this,
> but I don't follow c.l.py as closely as I used to.

It's new to me. :-)

> I've been writing a lot of C++ lately and my mind is stuck in limbo
> somewhere between C++ and Python.  I inadvertently wrote the following:
> 
> x = 0
> while x < 10:
>       # do something
>       ++x
> 
> Interestingly, this runs, it just never terminates!  Looks like
> somehow ++x is being parsed as "+0 + x".  Shouldn't this construct
> be flagged as a syntax error?  
> 
> This happens with both 2.1 and 2.2

IMO not worth it changing the language.  Train yourself to write x++
instead. :-)

--Guido van Rossum (home page: http://www.python.org/~guido/)