Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.glorb.com!news-xfer.nntp.sonic.net!news.astraweb.com!border6.newsrouter.astraweb.com!not-for-mail From: Ben Finney Newsgroups: comp.lang.python Subject: Re: Interpreting Left to right? References: <4E043953.5080705@stoneleaf.us> <20110624195300.GJ6075@point.cs.wisc.edu> <4E04EFD4.6050309@stoneleaf.us> <20110624200618.GK6075@point.cs.wisc.edu> X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney Date: Sat, 25 Jun 2011 10:32:46 +1000 Message-ID: <878vsqoimp.fsf@benfinney.id.au> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:2pRQD0np6Lj9G32m6b1Gneey8zI= MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Lines: 36 Organization: Unlimited download news at news.astraweb.com NNTP-Posting-Host: f824e2ba.news.astraweb.com X-Trace: DXC=n[fAbT[D4Offj0fd2JZgghL?0kYOcDh@jN7:H2`MmAUcF8TiH9LRjfa]G;2>V^?kWcbEW9A[5UK?eNZ[SL`C\KgckH[l9EU243i Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:8422 Tycho Andersen writes: > On Fri, Jun 24, 2011 at 01:24:24PM -0700, Ned Deily wrote: > > http://docs.python.org/py3k/reference/simple_stmts.html#assignment-statements > > Perhaps I'm thick, but (the first thing I did was read the docs and) I > still don't get it. From the docs: > > "An assignment statement evaluates the expression list (remember that > this can be a single expression or a comma-separated list, the latter > yielding a tuple) and assigns the single resulting object to each of > the target lists, from left to right." Notice that, in the grammar given there, there is exactly one “expression list”, following *all* of the ‘=’s. The “target lists” are each to the left of an ‘=’. > For a single target, it evaluates the RHS and assigns the result to > the LHS. Thus > > x = x['foo'] = {} > > first evaluates > > x['foo'] = {} No, that's not an “expression list” by the grammar given in the docs. The expression list consists, in your example, of “{}” only. The target lists are “x”, then “x['foo']”, in that order. -- \ “If consumers even know there's a DRM, what it is, and how it | `\ works, we've already failed.” —Peter Lee, Disney corporation, | _o__) 2005 | Ben Finney