Re: [Python-ideas] iterable.__unpack__ method

Discussion in 'Python' started by Chris Angelico, Feb 24, 2013.

  1. On Mon, Feb 25, 2013 at 1:16 AM, Steven D'Aprano <> wrote:
    > On 24/02/13 23:59, Chris Angelico wrote:
    >>
    >> On Sun, Feb 24, 2013 at 10:25 PM, Larry Hastings <>
    >> wrote:
    >>>
    >>> Or
    >>>
    >>> command, subcommand = next(iterargs), next(iterargs)

    >>
    >>
    >> Err.... is there a language guarantee of the order of evaluation in a
    >> tuple, or is this just a "CPython happens to evaluate independent
    >> expressions left-to-right"? This is totally broken if the next() calls
    >> could be done in either order.

    >
    > It's a language guarantee.
    >
    > http://docs.python.org/2/reference/expressions.html#evaluation-order


    Ah, so it is. My bad, sorry! In that case, sure, this works. It still
    violates DRY though, naming the iterable twice and relying on the
    reader noticing that that means "take two off this one". But that's a
    much weaker concern.

    ChrisA
     
    Chris Angelico, Feb 24, 2013
    #1
    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:
    2
    Views:
    366
    James Stroud
    Dec 10, 2008
  2. Anjanesh Lekshminarayanan

    Method returning an Iterable Object

    Anjanesh Lekshminarayanan, Jan 26, 2009, in forum: Python
    Replies:
    6
    Views:
    266
    Terry Reedy
    Jan 27, 2009
  3. Tim Chase
    Replies:
    0
    Views:
    74
    Tim Chase
    Feb 24, 2013
  4. Chris Angelico
    Replies:
    0
    Views:
    103
    Chris Angelico
    Feb 24, 2013
  5. Nick Mellor
    Replies:
    3
    Views:
    110
    Thomas Rachel
    Mar 13, 2013
Loading...

Share This Page