Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2a.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.06; '"""': 0.07; 'compiler': 0.07; 'elegant': 0.07; 'smallest': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'spec': 0.09; 'subject: [': 0.09; 'subject:language': 0.09; 'variable,': 0.09; 'check?': 0.16; 'partly': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'language': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'value.': 0.19; 'input': 0.22; 'programming': 0.22; 'header:User-Agent:1': 0.23; 'initial': 0.24; 'header:X-Complaints-To:1': 0.27; 'idea': 0.28; 'chris': 0.29; "doesn't": 0.30; 'that.': 0.31; 'usually': 0.31; 'break;': 0.31; 'gcc': 0.31; 'probably': 0.32; 'fri,': 0.33; 'guess': 0.33; '"the': 0.34; 'could': 0.34; 'definition': 0.35; 'test': 0.35; 'but': 0.35; 'version': 0.36; 'c++': 0.36; 'possible': 0.36; 'two': 0.37; 'depends': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'most': 0.60; 'tell': 0.60; "you're": 0.61; 'fire': 0.65; 'between': 0.67; 'mar': 0.68; 'guaranteed': 0.75; 'introduce': 0.78; 'condition.': 0.84; 'otten': 0.84; 'subject:NOT': 0.84; 'valid,': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Python language hack for C-style programmers [DO NOT USE!] :-) Date: Fri, 28 Mar 2014 09:26:05 +0100 Organization: None References: <20140327110856.14991bb0@bigbox.christie.dr> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p57bd9041.dip0.t-ipconnect.de User-Agent: KNode/4.11.5 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: 1395995177 news.xs4all.nl 2901 [2001:888:2000:d::a6]:55904 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69256 Chris Angelico wrote: > On Fri, Mar 28, 2014 at 6:46 PM, Peter Otten <__peter__@web.de> wrote: >> Why would you guess if you can check? Just fire up the interactive >> interpreter^W^W compiler: > > Partly because there's a difference between valid C++ and valid input > to the G++ compiler :) Knowing that it works with g++ doesn't tell me > that it's actually valid, and I don't feel like digging into the specs > to find out where you're guaranteed to be allowed to do that. (I could > probably test it with one of the language spec options, but then it > still depends on the exact version of GCC and the exact spec chosen.) I don't have the spec handy, only an old copy of "The C++ Programming Language" which has """ To avoid accidental misuse of a variable, it is usually a good idea to introduce the variable into the smallest scope possible [and] to delay the definition of a local variable until one can give it an initial value. [...] One of the most elegant applications of these two principles is to declare a variable in a condition. Consider: if (double d = prim(true)) { left /= d; break; } """