Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'terry': 0.07; 'python': 0.08; '(right': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'nameerror:': 0.09; 'question:': 0.09; 'received:gator410.hostgator.com': 0.09; '~ethan~': 0.09; 'am,': 0.13; 'defined': 0.14; 'wrote:': 0.15; 'evaluates': 0.16; 'happens:': 0.16; 'interprets': 0.16; 'reedy': 0.16; 'rhs': 0.16; '>>>': 0.16; '(most': 0.21; 'header:In-Reply-To:1': 0.22; 'dictionary': 0.23; 'traceback': 0.25; 'right.': 0.28; 'bound': 0.29; 'expressions': 0.29; 'example': 0.30; 'see,': 0.30; 'subject:?': 0.31; 'header:User-Agent:1': 0.34; 'to:addr:python- list': 0.34; 'last):': 0.35; 'file': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'order': 0.62; 'received:websitewelcome.com': 0.65; 'received:184': 0.67; '12:32': 0.84; '-->': 0.91 Date: Fri, 24 Jun 2011 00:14:27 -0700 From: Ethan Furman User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: python-list@python.org Subject: Re: Interpreting Left to right? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: c-67-170-168-84.hsd1.or.comcast.net ([192.168.74.5]) [67.170.168.84]:2181 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== 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: 30 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308899719 news.xs4all.nl 14146 [::ffff:82.94.164.166]:45844 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:8352 Terry Reedy wrote: > On 6/24/2011 12:32 AM, Chetan Harjani wrote: >> x=y="some string" >> And we know that python interprets from left to right. > > Read the doc. "5.14. Evaluation order > Python evaluates expressions from left to right. Notice that while > evaluating an assignment, the right-hand side is evaluated before the > left-hand side." The example given to me when I had this question: --> x = x['huh'] = {} --> x {'huh': {...}} As you can see, the creation of the dictionary is evaluated, and bound to the name 'x'; then the key 'huh' is set to the same dictionary. If you try that the other way 'round this happens: >>> x['huh'] = x = {} Traceback (most recent call last): File "", line 1, in NameError: name 'x' is not defined So -- the RHS (right hand side) gets evaluated first, then the LHSs from left to right. ~Ethan~