About Modifying Globals
Chris Angelico
rosuav at gmail.com
Thu Dec 4 18:58:13 EST 2014
On Fri, Dec 5, 2014 at 10:54 AM, Dave Angel <davea at davea.name> 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
More information about the Python-list
mailing list