Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.03; 'broken': 0.03; 'subject:Python': 0.05; 'expressions': 0.07; 'works.': 0.07; 'subject:method': 0.09; 'sure,': 0.09; 'thread,': 0.09; 'violates': 0.09; 'cc:addr:python-list': 0.10; 'language': 0.14; '(sorry': 0.16; '-tkc': 0.16; 'ah,': 0.16; 'command,': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'iterable': 0.16; 'itertools': 0.16; 'naming': 0.16; 'subject:ideas': 0.16; 'tuple,': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'subject:] ': 0.19; 'discussion': 0.20; 'import': 0.21; 'subject:skip:i 10': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header :In-Reply-To:1': 0.25; 'looks': 0.26; 'order.': 0.27; 'chris': 0.28; 'concern': 0.29; 'concern.': 0.29; 'case,': 0.29; "i'm": 0.29; 'evaluation': 0.30; 'url:python': 0.32; 'could': 0.32; 'done': 0.34; 'there': 0.35; 'but': 0.36; 'url:org': 0.36; 'totally': 0.36; 'charset:us-ascii': 0.36; 'two': 0.37; 'url:docs': 0.38; 'subject:-': 0.40; 'your': 0.60; 'email name :python-list': 0.62; 'evaluate': 0.62; 'is.': 0.62; 'skip:n 10': 0.63; 'dry': 0.84; 'received:50.22': 0.84; 'url:reference': 0.84; 'received:108': 0.91 Date: Sun, 24 Feb 2013 08:44:53 -0600 From: Tim Chase To: Chris Angelico Subject: Re: [Python-ideas] iterable.__unpack__ method In-Reply-To: References: <5129F8C4.4080307@hastings.org> <512A20A3.1020006@pearwood.info> X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1361717014 news.xs4all.nl 6873 [2001:888:2000:d::a6]:56090 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:39747 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