Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'parameters': 0.04; 'cpython': 0.05; 'abuse': 0.07; 'definition,': 0.09; 'freedom,': 0.09; 'oh,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'target,': 0.09; 'def': 0.12; 'ah,': 0.16; 'func():': 0.16; 'new:': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'statement.': 0.16; 'subject:bound': 0.16; 'wrote:': 0.18; 'dependent': 0.19; '>>>': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'received:comcast.net': 0.24; 'math': 0.24; 'defined': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'statement': 0.30; "d'aprano": 0.31; 'enforce': 0.31; 'steven': 0.31; 'subject:what': 0.31; 'class': 0.32; 'url:python': 0.33; 'something': 0.35; 'good.': 0.35; 'but': 0.35; 'url:org': 0.36; 'should': 0.36; 'two': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'future': 0.60; 'url:3': 0.61; 'strictly': 0.61; 'subject:The': 0.64; 'guaranteed': 0.75; 'batchelder': 0.84; 'silently': 0.84; 'subject:gets': 0.84; 'url:reference': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ned Batchelder Subject: Re: The binding operator, and what gets bound to what Date: Fri, 05 Dec 2014 07:56:26 -0500 References: <548113f3$0$13003$c3e8da3$5496439d@news.astraweb.com> <548180ae$0$13007$c3e8da3$5496439d@news.astraweb.com> <5481a63d$0$12992$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: c-50-133-228-126.hsd1.ma.comcast.net User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <5481a63d$0$12992$c3e8da3$5496439d@news.astraweb.com> 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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1417784195 news.xs4all.nl 2872 [2001:888:2000:d::a6]:51234 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82003 On 12/5/14 7:34 AM, Steven D'Aprano wrote: > Ned Batchelder wrote: > >> On 12/5/14 4:53 AM, Steven D'Aprano wrote: >>> Oh, I learned something new: strictly speaking, this is implementation- >>> dependent and not guaranteed to work in the future! >>> >>> def func(): >>> global math >>> import math >> >> I don't think this is implementation-dependent. > > The docs say that it is: > > https://docs.python.org/3/reference/simple_stmts.html#the-global-statement > > Names listed in a global statement MUST NOT [emphasis added] be > defined as formal parameters or in a for loop control target, > class definition, function definition, or import statement. > > CPython implementation detail: The current implementation does not > enforce the two restrictions, but programs should not abuse this > freedom, as future implementations may enforce them or silently > change the meaning of the program. Ah, good. TIL! :) -- Ned Batchelder, http://nedbatchelder.com