Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #8422
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Interpreting Left to right? |
| References | (3 earlier) <20110624195300.GJ6075@point.cs.wisc.edu> <4E04EFD4.6050309@stoneleaf.us> <20110624200618.GK6075@point.cs.wisc.edu> <nad-C01F34.13242424062011@news.gmane.org> <mailman.389.1308949722.1164.python-list@python.org> |
| Date | 2011-06-25 10:32 +1000 |
| Message-ID | <878vsqoimp.fsf@benfinney.id.au> (permalink) |
| Organization | Unlimited download news at news.astraweb.com |
Tycho Andersen <tycho@tycho.ws> 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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Interpreting Left to right? Tycho Andersen <tycho@tycho.ws> - 2011-06-24 16:08 -0500 Re: Interpreting Left to right? Ben Finney <ben+python@benfinney.id.au> - 2011-06-25 10:32 +1000 Re: Interpreting Left to right? Chris Torek <nospam@torek.net> - 2011-06-25 18:44 +0000
csiph-web