why no ++?

chris liechti cliechti at mails.ch
Fri Aug 3 20:40:22 CEST 2001


[posted and mailed]

Mark Robinson <m.1.robinson at herts.ac.uk> wrote in 
news:3B6A6B97.2060306 at herts.ac.uk:

> Just wondering. Can anyone tell me the rationale for leaving the ++/-- 
> operator out of python. It is perhaps my only irritation with python, it
> is just that I hate to have to write:
> 
> x = x + 1

that does load x modifies it and saves the value to x. x is touched twice.

x += 1

does touch x only once and it supported in newer python versions.

> 
> when my whole being just yearns to type
> 
> x++

this touches x once

"++" and "--" are old idioms that are left from C. the idea of that was to 
use "inc" and "dec" assembler instructions but that was before compliers 
knew optimizations.

> I guess it is perhaps not as clear, but I am not aware of it being a
> common cause of errors in C++ or java (doesn't mean it isn't, just that
> I am not aware of them). I also miss +=, *=, %=, /=, would it really 
> make the code that much harder to read/maintain?

have you tried python 2.0 or up? they know += and so


-- 
chris <cliechti at mails.ch>




More information about the Python-list mailing list