Path: csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'none,': 0.05; 'none)': 0.07; 'cc:addr:python-list': 0.09; 'specifying': 0.09; 'python': 0.10; 'def': 0.13; '231': 0.16; 'cc:name:python': 0.16; 'eval': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'namespace.': 0.16; 'wrote:': 0.16; '>>>': 0.20; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'exec': 0.22; 'function,': 0.22; 'sep': 0.22; 'am,': 0.23; 'sat,': 0.23; 'import': 0.24; 'header :In-Reply-To:1': 0.24; 'module': 0.25; 'message- id:@mail.gmail.com': 0.27; 'rules': 0.31; 'maybe': 0.33; 'received:google.com': 0.35; 'star': 0.35; 'subject:: ': 0.37; '12,': 0.37; 'things': 0.38; 'mean': 0.38; 'chrisa': 0.84; 'huh?': 0.84; 'specialised': 0.84; 'to:none': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=O66KHnRYl759mT3LjFThwCrtbzMDb2mJZ8LClarVQO4=; b=kbH85WsHs2SbDnfU4i7L994TfuFzZbGeXJ/r0sAoMDVv8S7gPmhR/AyOT82hrMiale k1+26z/K3RdTnfguFO5M1fP/UGeNwywLBjJ/cnBxK/PYuHJ0RYFQheSg2debllLl4iXv j7cTVCOwYSCOJ9SDJNvJml135OEB7FUeYM/1MBw3/7gqDa7zbK2P/UFYcSRx3sjaM2nJ NDS4ZV5+gUXKEDdtJR5nynTmS/bNW+RBdsI2+m+FfyIzWJnZnMfmD4wu1BxOS23KFGlA Oz66Wh5XXqaIqg0Qf3F7TrJx64Vfe0Epl35rwQGIGD0bZd7S8foToD61Ohp2HBXfodR2 +Ujw== MIME-Version: 1.0 X-Received: by 10.107.41.142 with SMTP id p136mr4444534iop.19.1441984514767; Fri, 11 Sep 2015 08:15:14 -0700 (PDT) In-Reply-To: References: <55f293da$0$1640$c3e8da3$5496439d@news.astraweb.com> Date: Sat, 12 Sep 2015 01:15:14 +1000 Subject: Re: Python handles globals badly. From: Chris Angelico Cc: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1441984523 news.xs4all.nl 23836 [2001:888:2000:d::a6]:57874 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96346 On Sat, Sep 12, 2015 at 1:03 AM, Ian Kelly wrote: >> There's also a bunch of specialised and complicated rules for what happens >> if you make a star import ("from module import *") inside a function, or >> call eval or exec without specifying a namespace. Both of these things are >> now illegal in Python 3. > > Huh? > >>>> exec("x = 42") >>>> x > 42 >>>> exec("x = 43", None, None) >>>> x > 43 > > That's in Python 3.4.0. Maybe I don't understand what you mean by > "without specifying a namespace". *inside a function* >>> def f(): ... exec("x = 42") ... print(x) ... >>> x = 231 >>> f() 231 ChrisA