I really prefer that this not need a keyword at all. I know lexical scope takes a second to get used to the first time you see it but it really is "the right behavior" and I don't see why Python just doesn't support it.
python is lexically scoped; you just can't re-bind variables from a different scope without the keyword. in the first lexically scoped versions of Python (2.0-2.1?) you could, but guido had it taken out because he felt that the potential confusion outweighed the benefits.
in current python versions you either have to use a global or a container object as a workaround. which is gross and I wish guido hadn't done that, but on the whole python is still better than the alternatives. :)
View all comments
Show parent comment
1
u/jbellis Apr 12 '08
the nonlocal keyword will allow this in python 3.0 (not sure about 2.6)