auto increment

BartC bc at freeuk.com
Fri Mar 4 10:02:51 EST 2011



"Chris Rebert" <clp2 at rebertia.com> wrote in message 
news:mailman.596.1299215244.1189.python-list at python.org...
> On Thu, Mar 3, 2011 at 9:05 PM, Dan Stromberg <drsalists at gmail.com> wrote:
>> On Thu, Mar 3, 2011 at 8:48 PM, Chris Rebert <clp2 at rebertia.com> wrote:
>>> On Thu, Mar 3, 2011 at 8:41 PM, monkeys paw <monkey at joemoney.net> wrote:
>>> > Does python have an analogy to c/perl incrementer?
>>> >
>>> > e.g.
>>> >
>>> > i = 0
>>> > i++
>>>
>>> i += 1
>>>
>>> If you're doing this for a list index, use enumerate() instead.
>>
>> There's been discussion of adding i++ to python, but it was felt that the
>> small number of saved keystrokes didn't justify the resulting bugs.  I
>> agree.
>
> Out of curiosity, what resulting bugs?

Probably things like i=(++i)+(--i), although more of being indeterminate 
than a bug.

That assumes that ++i was intended for use in an expression, rather than 
just be a statement.

-- 
Bartc 




More information about the Python-list mailing list