Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.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.020 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'implied,': 0.09; 'received :mail-qc0-f174.google.com': 0.09; 'subject:while': 0.09; 'cc:addr :python-list': 0.10; 'def': 0.10; '_do_': 0.16; 'oct': 0.16; 'simpson': 0.16; 'subject:expression': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'defined': 0.22; 'cc:2**0': 0.23; 'this:': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'right.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'fri,': 0.30; 'function': 0.30; 'url:python': 0.32; 'received:google.com': 0.34; 'clear': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'url:org': 0.36; 'should': 0.36; 'does': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'url:docs': 0.38; 'header:Received:5': 0.40; 'side': 0.61; '26,': 0.65; 'evaluation.': 0.84; 'url:reference': 0.84; 'effects.': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=/y/Mdsp9KRKoVwwF59jSsqseoLljD4G3HtgGctah0Ro=; b=pHt/t2G99jUxehRq3/ohvpGZsCs0TyryBbC0tUNt29c70hNHx7DJMgVQyDB+R65wD2 +rnUB+RXVPMBi4j8tQH6bkTMU0nxLaRFy32U2zS3ddYVsOf+FKcMM/FDCVgZlEaouOPt UWheVKyfM4XpGuMc+c2mQt23Hyv6IKvzamQINOtzEWV5CENKoTncZCEavfK4TSP/iE3A VB0QFtv3KyC+6NLnMoBb4qGjnFAaOMegdFzTlT7ceN4cnh6/Q+hke9udQmGl6C/K4g2n HKp5tjskH5HX8lMHe8n8OyifupiVhkeh2+UM+G1Vf3hl9VSp64goCkzXhlySMWL9e/HP qZsg== MIME-Version: 1.0 In-Reply-To: <20121026220338.GA25126@cskk.homeip.net> References: <7xlietjjsd.fsf@ruckus.brouhaha.com> <20121026220338.GA25126@cskk.homeip.net> From: Devin Jeanpierre Date: Fri, 26 Oct 2012 19:41:52 -0400 Subject: Re: while expression feature proposal To: Cameron Simpson Content-Type: text/plain; charset=UTF-8 Cc: "comp.lang.python" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351294955 news.xs4all.nl 6951 [2001:888:2000:d::a6]:46647 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32246 On Fri, Oct 26, 2012 at 6:03 PM, Cameron Simpson wrote: > Any doco would need to make it clear that no order of operation is > implied, so that this: > > x = 1 > y = (2 as x) + x > > does not have a defined answer; might be 2, might be 3. Just like any > other function call with side effects. But function calls with side effects _do_ have a defined order of evaluation. Left to right. And the answer should be 4. http://docs.python.org/reference/expressions.html#evaluation-order >>> def set_(d, k, v): ... d[k] = v ... return v ... >>> d = {} >>> set_(d, 'x', 1) 1 >>> set_(d, 'y', set_(d, 'x', 2) + d['x']) 4 -- Devin