integers

Joshua Marshall jmarshal at mathworks.com
Tue Jun 5 17:30:14 EDT 2001


Jonathan Gardner <gardner at cardomain.com> wrote:
> Locke wrote:
>> is there such thing as
>> someint++
>> or
>> someint--
>> or
>> someint += 2
>> in python??
>> 
>> it is a pain in the butt writing
>> someint = someint + 1
>> 
>> Thanks!

> It's also a pain in the butt writing someint += 1 (Yes, I know I am very 
> lazy).

> What is the reason that python doesn't have increment or decrement 
> operators?

Python isn't C - there's no reason to expect ++ or --.  And I'd
personally be against adding these to the language, since += and -= do
increment and decrement nicely.  Also, if ++ and -- were introduced
people would probably expect them to be expressions (since they look
like C's ++ and --).  This would be another mistake, in my opinion.  I
like how Python keeps side-affecting language constructs in the realm
of statements.



More information about the Python-list mailing list