[Python-Dev] replacing 'global'

Just van Rossum just at letterror.com
Sun Oct 26 10:58:13 EST 2003


Aahz wrote:

> Sounds good to me.  Question: what does this do?
> 
>     def f():
>         def g(x):
>             z := x
>         g(3)
>         print z
>         return g
>     g = f()
>     print z
>     g('foo')
>     print z
> 
> 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 NameError or UnboundLocalError or a new
NameError subclass. "In the face of ambiguity, etc."

Just



More information about the Python-Dev mailing list