[Python-3000] Draft PEP for outer scopes
Fredrik Lundh
fredrik at pythonware.com
Thu Nov 2 10:59:40 CET 2006
Talin wrote:
> One thing I don't understand in this discussion of re-purposing the
> 'global' keyword is how you handle the case of an inner function that
> *creates* a global.
>
> Right now, you can create a global variable from within a scope, even if
> that variable hasn't been declared yet:
>
> def foo():
> global x
> x = 1
>
> foo()
> print x
>
> However, if 'global' is simply a synonym for 'nonlocal', then how does
> it know *which* scope to create the variable in?
since what's a free variable and not is determined by static analysis,
and free variables are "owned" by the innermost scope they're used in,
I'm not sure why you even asking that question.
</F>
More information about the Python-3000
mailing list