Nested scopes resolution -- you can breathe again!

Russell Turpin rturpin at do.not.use
Sat Feb 24 18:06:09 CET 2001


Fri, 23 Feb 2001 09:01:19 -0800, Russell E. Owen
<owen at astrono.spamwashington.emu> pisze:
>> I suggested .. scaling back the proposal to allow it 
>> to be simpler and more regular, for example have a 
>> keyword or other explicit notation to say "this 
>> variable is not in local scope".

The best argument for this is that it is more EXPLICIT.
Currently, the "global" keyword is required to set a 
variable outside local scope. Simple reference, though,
is automatic. This is consistent with automatic 
declaration, though in both cases, it risks program
errors. I suspect an option that requires explicit 
declaration is one of the more frequent requests by
Python programmers. 

Marcin 'Qrczak' Kowalczyk wrote:
> I would certainly not call it simpler. Maybe for 
> the language implementor, but not for the programmer, 
> which must search the expression for its free variables 
> to list them at the top, obscuring the program.

???

When a programmer writes the variable "x," they had 
better know, in that context, to what it refers. If
they don't, there is pretty low chance that the code
will work. And far from obscuring the intent, perhaps
the SINGLE, BEST practice a programmer can employ, to 
help those who come later understand their work, is 
to put a manifest of all variables at the top of each 
function, class, and module. 

Russell



More information about the Python-list mailing list