[Python-3000] Draft PEP for outer scopes
Josiah Carlson
jcarlson at uci.edu
Mon Nov 6 17:16:37 CET 2006
"Michael Urman" <murman at gmail.com> wrote:
> I personally expect that while there is a theoretical clash between
> variable names in nested scopes, that's already a poor coding
> decision. The module level globals should not unintentionally collide
> with function-local non-local access. Thus reusing the global keyword
> is not a practical limitation.
Just saying that they shouldn't be colliding doesn't mean that they
won't. I've seen horrendous code from some otherwise smart people where
locals shadow globals, even in closures. I don't have a link for you
because I've tried to block out the experience. However, in my opinion,
relying on good coding practices (never shadow variables) to guarantee
correctness of the use of the global keyword in Python seems to me to be
silly.
I hope we can all at least agree that *requiring* good coding practices
to make a feature work may be a bit more anal retentive than we want
Python to be. While I personally don't want the feature in the first
place, if I'm going to be seeing it in code, I would very much rather
that a second keyword were introduced. If only because then I wouldn't
tear out my hair trying to figure out whether a variable was really in
the module globals, or in just another containing scope.
- Josiah
More information about the Python-3000
mailing list