Path: csiph.com!usenet.pasdenom.info!news.albasani.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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'exception': 0.03; 'expressions': 0.07; 'implied,': 0.09; 'subject:while': 0.09; 'tuple': 0.09; 'stored': 0.10; '*instance*': 0.16; 'classes)': 0.16; 'expression,': 0.16; 'expressions,': 0.16; 'expressions.': 0.16; 'folding': 0.16; 'oct': 0.16; 'precedence.': 0.16; 'simpson': 0.16; 'subject:expression': 0.16; 'wrote:': 0.17; 'exists': 0.17; 'bit': 0.21; 'defined': 0.22; 'this:': 0.23; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'allowed,': 0.29; 'cases.': 0.29; 'probably': 0.29; 'class': 0.29; 'fri,': 0.30; 'received:209.85.215.46': 0.30; 'function': 0.30; 'stuff': 0.30; 'code': 0.31; 'anywhere': 0.33; 'docs': 0.33; 'anyone': 0.33; 'to:addr:python-list': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'clear': 0.35; 'expected': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'method': 0.36; 'bad': 0.37; 'does': 0.37; 'uses': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'side': 0.61; 'back': 0.62; 'is.': 0.62; 'please,': 0.62; 'different': 0.63; '26,': 0.65; 'actually,': 0.84; 'to:name:python': 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 :content-type; bh=4eTESNerRYeOSSSOEgqck5w/jajtybZ8+y8WuOkUPVk=; b=USn9kFVUshG6AlJs8lyuctwTA+b5T465jBVqzEVGGrpfnmNAqjasSFAXi5vZylRy7N qYPBNfgZqNu1oVIx8VyHwIr5CTboqDa/JXvCT7O67PSI1BQa+9oawaGaJf57ixJY/bL/ y84I2PuP9U7hhz0l5fIXsgMrxcZau76fScoFvFLlT6TCe/YQH6Tzz/GUXCgbAlKz9KMY cpZN92LAq0eItAQC7ZcRQerh7qeTGhfuTrTHr8JQgjjgyIoNZ77EwxF6AF5d9ANSUD0o LlH0QfzN0f+Em6tnfTh2/K6Q3wFFGxDD/1JFsXk0XMPkiMu6dwBW0BII1YEg/5IL/Hym YaHA== MIME-Version: 1.0 In-Reply-To: <20121026220338.GA25126@cskk.homeip.net> References: <7xlietjjsd.fsf@ruckus.brouhaha.com> <20121026220338.GA25126@cskk.homeip.net> From: Ian Kelly Date: Fri, 26 Oct 2012 16:48:05 -0600 Subject: Re: while expression feature proposal To: Python Content-Type: text/plain; charset=ISO-8859-1 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351291717 news.xs4all.nl 6895 [2001:888:2000:d::a6]:53038 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32241 On Fri, Oct 26, 2012 at 4:03 PM, Cameron Simpson wrote: > It will work anywhere an expression is allowed, and superficially > doesn't break stuff that exists if "as" has the lowest precedence. Please, no. There is no need for it outside of while expressions, and anywhere else it's just going to be bad practice. Even if it's considered an expression, let's only allow it in while expressions. > 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. Actually, the docs are clear that expressions are evaluated left to right, so the expected result of the above would be 4. > It would probably mean folding the except/with "as" uses back into > expressions and out of the control-structural part of the grammar. I can't > see that that would actually break any existing code though - anyone else? Yes it would, because the meaning is a bit different in both of those cases. For except, the result of the expression (an exception class or tuple of classes) is not stored in the target; the exception *instance* is. Similarly for with, the result of the expression is not stored; the result of calling its __enter__ method is, which is often but not always the same thing.