Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100121
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: increment/decrement operators |
| Date | 2015-12-07 17:24 -0700 |
| Message-ID | <mailman.42.1449534294.12405.python-list@python.org> (permalink) |
| References | <dcg4apF3gq3U1@mid.individual.net> <n3umug$f0$1@news.albasani.net> <20151205094115.01751274@imp> <mailman.225.1449330245.14615.python-list@python.org> <n3v653$g0g$1@dont-email.me> |
On Dec 5, 2015 10:21 AM, "BartC" <bc@freeuk.com> wrote: > > > The latter is not the same. Some of the differences are: > > * ++ and -- are often inside inside expressions and return values (unlike x+=1 in Python) > > * x++ and x-- return the /current/ value of x, unlike x+=1 even if it were to return a value; it would be the new value Since x+=1 is not an expression, this is moot. > * x+=1 requires you to hard-code the value 1, but ++ is not necessarily stepping by 1. You can imagine ++ stepping something to its next value. Note that x+=1 does not necessarily have to mean stepping by 1 either. You could even do something like x+=5 to mean skip the next four values and step x to the value after that. > However, if ++ and -- are only used as statements, then why not simply map them to x+=1? In Python, that would need to be x++ and x-- as ++x or --x have existing meanings. I think a better question is if they're only going to be statements, then why bother adding them? x++ doesn't give you anything you can't get from x+=1, so why commit to supporting the extra syntax?
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
increment/decrement operators Tony van der Hoff <tony@vanderhoff.org> - 2015-12-05 12:40 +0000
Re: increment/decrement operators Robin Koch <robin.koch@t-online.de> - 2015-12-05 13:56 +0100
Re: increment/decrement operators Tony van der Hoff <tony@vanderhoff.org> - 2015-12-05 14:14 +0000
Re: increment/decrement operators "D'Arcy J.M. Cain" <darcy@VybeNetworks.com> - 2015-12-05 09:41 -0500
Re: increment/decrement operators Terry Reedy <tjreedy@udel.edu> - 2015-12-05 10:43 -0500
Re: increment/decrement operators BartC <bc@freeuk.com> - 2015-12-05 17:18 +0000
Re: increment/decrement operators Ian Kelly <ian.g.kelly@gmail.com> - 2015-12-07 17:24 -0700
csiph-web