autoincrementing

Harvey Thomas hst at empolis.co.uk
Tue Feb 25 08:00:03 EST 2003


Dale Strickland-Clark wrote
> 
> Alex Martelli <aleax at aleax.it> wrote:
> 
> >
> >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
> 
> That is not the point of auto-increment (and I'm sure you must know
> this)
> 
>    intPrev = intNew++
> 
> is equivalent to:
> 
>    intPrev = intNew
>    intNew += 1
> 
> Rather more than one character saved. And there are times when it can
> save you a lot more than that, too.
> --
> Dale Strickland-Clark
> Riverhall Systems Ltd
> -- 

Surely, the main point is that

i += 1

is an assignment statement

and

i++

is an expression. Python makes a clear distinction between expressions and functions. Implementing i++ would give in-line assignment which the BDFL is apparently set against (so am I in the form if a = b..., but wouldn't mind if a := b...).

_____________________________________________________________________
This message has been checked for all known viruses by the MessageLabs Virus Scanning Service.





More information about the Python-list mailing list