This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: shorter code with 'i++'
Type: enhancement Stage:
Components: None Versions:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: mwh Nosy List: amc1, gregsmith, mwh, tflorek, voodmania
Priority: normal Keywords:

Created on 2001-05-20 20:50 by tflorek, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Messages (5)
msg53149 - (view) Author: Tobias Florek (tflorek) Date: 2001-05-20 20:50
what about making an operator similar to c and javas '++' 
(e.g., you want to increase something by 1, why writing 'i = i + 1', why not simply 'i++'?)

it would make python not that much perlisher (more complicated) but bit shorter.
msg53150 - (view) Author: Allan Crooks (amc1) Date: 2001-06-12 02:37
Logged In: YES 
user_id=39733

Just to make sure, you do know you can do i+=1, don't you? :)
msg53151 - (view) Author: Alberto Fernandez Valiente (voodmania) Date: 2001-06-25 08:46
Logged In: YES 
user_id=253336

Yes, we have i+=1, but me like others started with c/c++.
I use i=i+1 but I think code will be more "readable" with 
i++.
msg53152 - (view) Author: Gregory Smith (gregsmith) Date: 2001-09-15 00:58
Logged In: YES 
user_id=292741

I started with C about 20 years ago, and I'm neutral/negative on this. It would
lead to needing a __inc__() and __dec__() function for overloading,  and if you
allow a[i++] = .. then you gotta have a[++i] too so that's __pinc__ and
__pdec__, and before you know it people are complaining about a[i++] = i
not doing what they want, and next you're allowing assignments in
expressions and 'if a = 3' becomes legal, which I don't want.

but if you are only proposing i++ by itself as a statement,  i+=1 isn't much
worse; + and = are on the same key. Hey, they already saved you all those
semicolons and curly brackets.
msg53153 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2001-12-07 16:00
Logged In: YES 
user_id=6656

No chance.  This must have been done to death on
comp.lang.python, but I'm feeling too lazy to look it up
right now.
History
Date User Action Args
2022-04-10 16:04:04adminsetgithub: 34523
2001-05-20 20:50:03tflorekcreate