Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2a.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; 'python,': 0.02; 'assignment': 0.07; 'compiler': 0.07; 'cc:addr:python-list': 0.11; 'python': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'globals.': 0.16; 'wrote:': 0.18; 'normally': 0.19; 'otherwise,': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'somewhere': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; "doesn't": 0.30; 'dec': 0.30; 'statement': 0.30; 'message-id:@mail.gmail.com': 0.30; 'occurs': 0.31; 'subject:About': 0.31; 'yes.': 0.31; 'figure': 0.32; 'fri,': 0.33; 'not.': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'dave': 0.60; 'strictly': 0.61; 'angel': 0.91; 'to:none': 0.92 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=n6sH1Q358XucbIQULa+cTqdp9bZidasg4W3xn4JIu8Q=; b=zYEH1L7KcX8WIarp49jfA2hczL4AdCTc6S/PByvgVBurtrQj6Qnm5QWUQjKFlCbCRi 8QnKAcut8QleKgEK0q+9Y5/9RBwj9K2oF02VB8lTEJpnaxgIsyK3MtcF8CZKiH/1K3ff tUp2LnCaesVJ/ptirvWVVyVF/swfX75ZlY2WjYJ+tOdqsVKIkQ2TRsJ5J44RpbpYjOrU ACW9Dl2SwLB0RAPfeUX6gVGthKwJnztZx38mva0+zF2fuYDy54XPvryYjq8tGCzopzj7 w1aoHies4c1N7DKfBgOGHc0JcjwAZgh0ITNHaW3+e4IfjU3sMIcsRHEI+jH4me4Vywjb WRFg== MIME-Version: 1.0 X-Received: by 10.50.23.48 with SMTP id j16mr829509igf.34.1417737493914; Thu, 04 Dec 2014 15:58:13 -0800 (PST) In-Reply-To: <5480F432.4090803@davea.name> References: <5480F432.4090803@davea.name> Date: Fri, 5 Dec 2014 10:58:13 +1100 Subject: Re: About Modifying Globals From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 13 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1417737496 news.xs4all.nl 2911 [2001:888:2000:d::a6]:44981 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81964 On Fri, Dec 5, 2014 at 10:54 AM, Dave Angel wrote: > Python doesn't have declarations, so when a function is compiled, the > compiler has to infer what names are to be local and what are not. The rule > it normally uses is roughly based on whether an assignment occurs somewhere > inside the function. Not strictly true; Python just inverts the C model. In C, you declare your locals; in Python, you declare your globals. The "global x" statement is a declaration. But otherwise, yes. When a function is compiled, the compiler has to figure out what's local and what's global. ChrisA