[Python-Dev] ++x oddnes

Paul Prescod paulp@ActiveState.com
Sat, 11 Aug 2001 16:52:49 -0700

"M.-A. Lemburg" wrote:
> Why ? ++x can be put to some real use: I have a counter
> type which actually uses ++x to increment the counter.

Do you implement a matching "x++"? What's wrong with x.inc()?

> Note that the interpreter sees ++x as +(+x), that is the "+" is
> interpreted as unary + -- perfectly legal Python if you ask me.

Legal but perverse. Your users will expect +++x and x++ to be equally
valid and have their C semantics. Plus you are using a Python construct
that means one thing to mean something totally different just because it
means the totally different thing in other languages. In Python that
syntax would usually be side-effect free (and useless).
Take a recipe. Leave a recipe.  
Python Cookbook!  http://www.ActiveState.com/pythoncookbook