autoincrementing

Alex Martelli aleax at aleax.it
Tue Feb 25 04:00:34 EST 2003


Hilbert wrote:

> I've read somehwere the that newer versions of
> python support autoincrementing. I've just upgraded
> from 1.5.2 to 2.2.2, and
> 
> i=1
> i++
> 
> still gives me a syntax error. I can do
> 
> i+=1
> 
> however. Why doesn't i++ work?

For the same reason i?!@ doesn't work -- there is
no ++ operator in Python, just as there is no ?!@
operator (and MOST other sequences of special symbols
and punctuation are also not operators, thanks be).

Writing one more character to code +=1 instead of ++
is no great hardship, and it would be absurd for
Python to introduce a special operator just for the
purpose of saving that one character.


Alex





More information about the Python-list mailing list