Postfix/Prefix Operators (++,--)

Joshua Marshall joshway_without_spam at myway.com
Fri Jun 6 09:13:09 EDT 2003


Peter Hansen <peter at engcorp.com> wrote:
...

> Secondly, in Python assignment actually *rebinds* a name to a new
> object, so i = i + 1 creates a new object that is one greater than
> the old, and rebinds the name "i" to it (like a pointer).  The old
> value, if there are no more references to it, is destroyed.

> This, combined with the fact that these integer objects are actually
> *immutable* (they cannot be changed!) pretty much prevents any
> possibility of those operators working the way you'd expected.

++/-- can be added to Python, and could act in a way that wouldn't
surprise C or Java programmers.  There really isn't any conceptual
difference between references to immutabe ints and C/Java primitive
ints.

That said, I still agree adding ++/-- to Python is a bad idea.




More information about the Python-list mailing list