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; 'language': 0.14; '(sorry': 0.16; 'ah,': 0.16; 'command,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterable': 0.16; 'itertools': 0.16; 'naming': 0.16; 'subject:ideas': 0.16; 'tuple,': 0.16; 'typo.': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'tim': 0.18; '>>>': 0.18; 'subject:] ': 0.19; 'feb': 0.19; 'discussion': 0.20; 'import': 0.21; 'subject:skip:i 10': 0.22; 'posted': 0.22; 'header:In-Reply-To:1': 0.25; 'looks': 0.26; 'am,': 0.27; 'order.': 0.27; 'message- id:@mail.gmail.com': 0.27; 'chris': 0.28; 'chase': 0.29; 'concern': 0.29; 'concern.': 0.29; 'case,': 0.29; "i'm": 0.29; 'evaluation': 0.30; 'url:python': 0.32; 'could': 0.32; 'to:addr :python-list': 0.33; 'received:google.com': 0.34; 'wrong': 0.34; 'done': 0.34; 'list': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'url:org': 0.36; 'totally': 0.36; "didn't": 0.36; 'two': 0.37; 'received:209': 0.37; 'url:docs': 0.38; 'to:addr:python.org': 0.39; 'subject:-': 0.40; 'your': 0.60; 'email name:python-list': 0.62; 'evaluate': 0.62; 'is.': 0.62; 'skip:n 10': 0.63; '2013': 0.84; 'dry': 0.84; 'url:reference': 0.84; 'sorry.': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=W/LoV371N6Soosfv+ajCxUu1dsgSgL1LwzQb10vby0s=; b=nOSjpTLxdycBSvgkuCMJAQg7paco1S2aMpYmQn7gysWMg6bytaG+YqmQS/qShISZWv uZgIPzHy6vDxjDc4+hRBo52w4/mxq+0UDN9IelJ2Opmssu6TkLt+8GnRSJrJ1NrZWTGv C8W8r97H7U9QunqasP6NCiHt/eYK5WJq5aa4M+eYT4AAve1yePNTr2DSAI6wRo09kP18 a6UybKrZJ1ShCWo/BwyQYy/Twn3vWQeryPT8t7jpFrlUkzMrtmQB+Yuz8VLmg8rdLdkS 0X24IudzPpT2TfkpjB8FVMKDCzL+j0L+jZEqhPfmpBzBisFQoI/vgNhPJPxV+VVT3oO7 jdnw== MIME-Version: 1.0 X-Received: by 10.52.22.194 with SMTP id g2mr7610427vdf.91.1361717605803; Sun, 24 Feb 2013 06:53:25 -0800 (PST) In-Reply-To: <20130224084453.012d9e93@bigbox.christie.dr> References: <5129F8C4.4080307@hastings.org> <512A20A3.1020006@pearwood.info> <20130224084453.012d9e93@bigbox.christie.dr> Date: Mon, 25 Feb 2013 01:53:25 +1100 Subject: Re: [Python-ideas] iterable.__unpack__ method From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1361717615 news.xs4all.nl 6872 [2001:888:2000:d::a6]:59524 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:39748 On Mon, Feb 25, 2013 at 1:44 AM, Tim Chase wrote: > 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@). Blargh, it didn't migrate, I just posted to the wrong list courtesy of a typo. Sorry. ChrisA