Re: auto increment

Discussion in 'Python' started by Chris Rebert, Mar 4, 2011.

  1. Chris Rebert

    Chris Rebert Guest

    On Thu, Mar 3, 2011 at 9:05 PM, Dan Stromberg <> wrote:
    > On Thu, Mar 3, 2011 at 8:48 PM, Chris Rebert <> wrote:
    >> On Thu, Mar 3, 2011 at 8:41 PM, monkeys paw <> 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
    Chris Rebert, Mar 4, 2011
    #1
    1. Advertising

  2. Chris Rebert

    BartC Guest

    "Chris Rebert" <> wrote in message
    news:...
    > On Thu, Mar 3, 2011 at 9:05 PM, Dan Stromberg <> wrote:
    >> On Thu, Mar 3, 2011 at 8:48 PM, Chris Rebert <> wrote:
    >>> On Thu, Mar 3, 2011 at 8:41 PM, monkeys paw <> 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
    BartC, Mar 4, 2011
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    104
    Views:
    10,940
    Jordan Abel
    Oct 28, 2005
  2. Replies:
    99
    Views:
    2,481
    eliza81
    Jun 11, 2010
  3. linkswanted
    Replies:
    1
    Views:
    886
  4. Alf P. Steinbach /Usenet
    Replies:
    0
    Views:
    880
    Alf P. Steinbach /Usenet
    May 22, 2011
  5. Peng Yu

    post increment or pre increment?

    Peng Yu, Nov 21, 2008, in forum: Perl Misc
    Replies:
    7
    Views:
    510
    Peter J. Holzer
    Nov 23, 2008
Loading...

Share This Page