Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #39747 > unrolled thread

Re: [Python-ideas] iterable.__unpack__ method

Started byTim Chase <python.list@tim.thechases.com>
First post2013-02-24 08:44 -0600
Last post2013-02-24 08:44 -0600
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [Python-ideas] iterable.__unpack__ method Tim Chase <python.list@tim.thechases.com> - 2013-02-24 08:44 -0600

#39747 — Re: [Python-ideas] iterable.__unpack__ method

FromTim Chase <python.list@tim.thechases.com>
Date2013-02-24 08:44 -0600
SubjectRe: [Python-ideas] iterable.__unpack__ method
Message-ID<mailman.2406.1361717014.2939.python-list@python.org>
On 2013-02-25 01:19, Chris Angelico wrote:
> >>>      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.

Your DRY/readability concern might then be addressed by writing it as

  from itertools import islice
  # ...
  command, subcommand = islice(iterargs, 2)

(sorry if this was already addressed in the python-ideas@ thread,
since I'm not subscribed there and it looks like discussion migrated
to python-list@).

-tkc


[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web