Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed6.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.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'terry': 0.07; 'python': 0.08; 'ah,': 0.09; 'parsing': 0.09; 'statement.': 0.09; 'received:209.85.214.174': 0.13; 'received:mail- iw0-f174.google.com': 0.13; 'wrote:': 0.15; 'expression,': 0.16; 'reedy': 0.16; 'tmp': 0.16; 'unambiguous': 0.16; 'cc:addr:python- list': 0.16; 'pm,': 0.16; 'language': 0.21; 'cc:2**0': 0.21; 'cc:no real name:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'parse': 0.23; 'sort': 0.28; 'fri,': 0.28; 'received:209.85.214': 0.28; '24,': 0.29; 'cc:addr:python.org': 0.30; 'thanks': 0.30; 'subject:?': 0.31; 'does': 0.33; 'header:User-Agent:1': 0.34; 'things': 0.35; 'assignment': 0.35; 'charset:us-ascii': 0.36; 'received:google.com': 0.37; 'but': 0.37; 'received:209.85': 0.38; 'received:128': 0.38; 'subject:: ': 0.38; 'perhaps': 0.39; 'received:209': 0.39; 'case': 0.40; 'where': 0.40; 'more': 0.60; 'ever': 0.65; 'here.': 0.66; 'jun': 0.67; 'sides.': 0.84; 'thereof': 0.84 Date: Fri, 24 Jun 2011 16:21:38 -0500 From: Tycho Andersen To: Terry Reedy 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 23 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308951083 news.xs4all.nl 199 [::ffff:82.94.164.166]:39596 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:8413 On Fri, Jun 24, 2011 at 05:02:00PM -0400, Terry Reedy wrote: > 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". Ah, the point about the grammar is what I was missing. Thanks a bunch! \t