Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'compact': 0.09; 'rewrite': 0.09; 'subject:design': 0.09; 'burak': 0.16; 'elt': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterable': 0.16; 'subject:Language': 0.16; 'used).': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'thu,': 0.19; 'meant': 0.20; 'error': 0.23; 'expanded': 0.24; 'looks': 0.24; 'this:': 0.26; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; '(since': 0.31; 'assert': 0.31; 'sep': 0.31; 'received:google.com': 0.35; 'to:addr:python-list': 0.38; 'list,': 0.38; '12,': 0.39; 'to:addr:python.org': 0.39; 'length': 0.61; 'different': 0.65; 'presumably': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=sMIVbEoq4pnx/VDmD6/19zAxTWBbslIsuueVl2b7L98=; b=vGbNw7rkZKUgnpPAg/fz6liF/RJgKaWvFgACj29AH/ScdMi0cCV2oYoAv8LK4+yoHn JMuIDU1F1ClSpMCTyD1Jp7P9w//yfI+m9K+ljtwL5W6r4UbS16iDdu0XDODpRoqLNAr5 ephMUlAMHRoMK/g+9WDQd8oL5tMdIskiimv0CLMz9ql3RmkDLmQucIxa5Bpj/PLJTEbG d8ZdKC/WmM2hoxCBi6ZXccFw1yWYY+iQR94gGZEntYdZFlFbsGul5pl3LkxTtt0qBwGU SJaheaSya2FeQk+FsWTnQ5uYSnloX+hkR0XGP7RmEu9TyqN8d0bD1nhtxhtdJ64nCDiv Af/A== MIME-Version: 1.0 X-Received: by 10.58.136.4 with SMTP id pw4mr1616577veb.10.1378910762620; Wed, 11 Sep 2013 07:46:02 -0700 (PDT) In-Reply-To: References: <522eb795$0$29999$c3e8da3$5496439d@news.astraweb.com> Date: Thu, 12 Sep 2013 00:46:02 +1000 Subject: Re: Language design 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1378910771 news.xs4all.nl 15875 [2001:888:2000:d::a6]:41341 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:53969 On Thu, Sep 12, 2013 at 12:32 AM, Neil Cerutti wrote: > On 2013-09-11, Burak Arslan wrote: >> My favourite gotcha is this: >> >> elt, = elts >> >> It's a nice and compact way to do both: >> >> assert len(elts) == 0 >> elt = elts[0] > > I'm confused. Your rewrite looks like an assertion error or an > IndexError. Presumably he meant to assert that the length is 1. If elts is a list, then yes, these are equivalent, though the expanded form is actually a bit different (since any iterable can be used). ChrisA