[Python-Dev] replacing 'global'
Just van Rossum
just at letterror.com
Sun Oct 26 06:14:58 EST 2003
Skip Montanaro wrote:
> I see a couple problems:
> * Would you be required to use := at each assignment or just the
Just the first; "a = 2" still means "a is local to this scope".
> All the toy examples we pass around are very simple, but it
> seems that the name would get assigned to more than once, so the
> programmer might need to remember the same discipline all the time.
> It seems that use of
> x := 2
> x = 4
> should be disallowed in the same function so that the compiler can
> flag such mistakes.
I don't see it as a mistake. := would mean: "bind to whichever scope the
name is defined in", and that includes the current scope. I disagree
with Alex when he says := should mean "I'm binding this name in
> * This seems like a statement which mixes declaration and execution.
How is that different from "regular" assignment? It mixes declaration
and execution in the same way.
More information about the Python-Dev