[Python-Dev] replacing 'global'
Aahz
aahz at pythoncraft.com
Sun Oct 26 10:46:26 EST 2003
On Sun, Oct 26, 2003, Alex Martelli wrote:
>
> Keeping := Franciscan in its simplicity would make it easiest to
> implement, easiest to explain, AND avoid all sort of confusing cases
> where the distinction between := and = would otherwise be confusingly
> nonexistent. It would also make it most effective because it always
> means the same thing -- "assignment to (already-existing) nonlocal".
> This is much the spirit in which I'd forego the idea of making += etc
> access nonlocals too, though I guess I'm only -0 on that; it seems
> simplest and most effective to have the one concept "rebinding a
> nonlocal name" correspond in strict 1-1 way to the one notation := .
> Simplicity and effectiveness feel very Pythonic to me.
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.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"It is easier to optimize correct code than to correct optimized code."
--Bill Harlan
More information about the Python-Dev
mailing list