[Python-Dev] replacing 'global'
aleaxit at yahoo.com
Sun Oct 26 11:23:20 EST 2003
On Sunday 26 October 2003 04:46 pm, Aahz wrote:
> On Sun, Oct 26, 2003, Alex Martelli wrote:
> > nonexistent. It would also make it most effective because it always
> > means the same thing -- "assignment to (already-existing) nonlocal".
> Sounds good to me. Question: what does this do?
> def f():
> def g(x):
> z := x
> That is, in the absence of a pre-existing binding, where does the
> binding for := go? I think it should be equivalent to global, going to
> the module scope.
I think it should raise some subclass of NameError, because it's
not an assignment to an _already-existing_ nonlocal, as per my
text quoted above. It does not seem to me that "nested functions
able to rebind module-level names" has compelling use cases, so
I would prefer the simplicity of forbidding this usage.
More information about the Python-Dev