Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed2.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.06; 'error:': 0.07; '#include': 0.09; '(first': 0.09; 'identifier': 0.09; 'if,': 0.09; 'main()': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject: [': 0.09; 'subject:language': 0.09; 'yeah,': 0.09; 'afaik.': 0.16; 'c++)': 0.16; 'check?': 0.16; 'for,': 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; 'wrote:': 0.18; 'variable': 0.18; '>>>': 0.22; 'appears': 0.22; '(in': 0.22; 'header:User- Agent:1': 0.23; 'certain': 0.27; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'gcc': 0.31; 'fri,': 0.33; 'guess': 0.33; 'but': 0.35; 'expected': 0.38; 'ends': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'reported': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'dave': 0.60; 'expression': 0.60; 'new': 0.61; 'fire': 0.65; 'note:': 0.66; 'mar': 0.68; 'subject:NOT': 0.84; 'angel': 0.91 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 08:46:29 +0100 Organization: None References: <20140327110856.14991bb0@bigbox.christie.dr> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit 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: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395992809 news.xs4all.nl 2877 [2001:888:2000:d::a6]:44086 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69254 Chris Angelico wrote: > On Fri, Mar 28, 2014 at 12:44 PM, Dave Angel wrote: >>> if (array m = Regexp.split2(some_pattern, some_string)) >>> do_something(m); >>> >> >> I don't know for certain about if, but you can declare (in C++) a >> new variable in for, which is a superset of if. Scope ends when >> the for does. > > Yeah, but only a for, AFAIK. Not an if or a while. Why would you guess if you can check? Just fire up the interactive interpreter^W^W compiler: $ cat ifdecl.c #include int main() { if(int i=42) printf("%d\n", i); } $ gcc ifdecl.c ifdecl.c: In function ‘main’: ifdecl.c:5:6: error: expected expression before ‘int’ if(int i=42) ^ ifdecl.c:6:20: error: ‘i’ undeclared (first use in this function) printf("%d\n", i); ^ ifdecl.c:6:20: note: each undeclared identifier is reported only once for each function it appears in $ g++ ifdecl.c $ ./a.out 42