Guido van Rossum <guido at python.org> writes: >> However, as long as we're talking about this stuff, I wish I could >> write "global foo" at module scope and have that mean "this variable >> is to be treated as global in all functions in this module". > > This is similar to Greg Ewing's proposable to have 'rebindable x' at > an outer function scope. My problem with it remains: > > It gives outer scopes (some) control over inner scopes. One of the > guidelines is that a name defined in an inner scope should always > shadow the same name in an outer scope, to allow evolution of the > outer scope without affecting local details of inner scope. (IOW if > an inner function defines a local variable 'x', the outer scope > shouldn't be able to change that.) Frankly, I wish Python required one to write explicit declarations for all variables in the program: var x, y, z # module scope class bar: classvar I, J, K # class variables var i, j, k # instance variables def foo(...): var a, b, c # function scope ... It's extra bondage and discipline, yeah, but it's that much more help comprehending the program six months later, and it also gets rid of the "how was this variable name supposed to be spelled again?" question. zw
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4