auto increment

Dan Stromberg drsalists at gmail.com
Fri Mar 4 00:23:21 EST 2011


On Thu, Mar 3, 2011 at 9:07 PM, Chris Rebert <clp2 at rebertia.com> wrote:

> 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?
>
> Cheers,
> Chris
>

EG:

if debug:
   print 'This is the %dth issue' % i++
warble = i * 65521

Then warble gets a different value depending on whether you're in debug mode
or not, and the source of the problem can take a few glances to catch.

Also, just using an expression in a statement context is a little... odd.  I
know it's the norm in some languages, but I like it that Python maintains a
clear distinction.  But if you disallow using an expression in a statement
context, then the usefulness of i++ is dramatically decreased.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110303/6d76c28d/attachment-0001.html>


More information about the Python-list mailing list