Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #8408 > unrolled thread

Re: Interpreting Left to right?

Started byTerry Reedy <tjreedy@udel.edu>
First post2011-06-24 17:02 -0400
Last post2011-06-24 17:02 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Interpreting Left to right? Terry Reedy <tjreedy@udel.edu> - 2011-06-24 17:02 -0400

#8408 — Re: Interpreting Left to right?

FromTerry Reedy <tjreedy@udel.edu>
Date2011-06-24 17:02 -0400
SubjectRe: Interpreting Left to right?
Message-ID<mailman.388.1308949343.1164.python-list@python.org>
On 6/24/2011 4:06 PM, Tycho Andersen wrote:

> tmp = {}
> x['huh'] = tmp # NameEror!
>
> That is, the right hand sides of assignments are evaluated before the
> left hand sides. That is (somehow?) not the case here.

You are parsing "a = b = c" as "a = (b = c)" which works in a language 
in which assignment is an expression, but does not work in Python where 
assignment is a statement. You have to parse it more as "(a = b) = c" 
but that does not work since then the first '=' is not what it seems. It 
is more like "(both a and b) = c". Perhaps best to expand "a = b = c" to 
"a = c; b = c" and see the first as an abbreviation thereof -- just 
delete the 'c;'.

If I have ever used this sort of multiple assignment, it has been for 
simple unambiguous things like "a = b = 0".

-- 
Terry Jan Reedy

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web