PyWart: Namespace asinitiy and the folly of the global statement

Steven D'Aprano steve+comp.lang.python at pearwood.info
Fri Feb 8 12:45:58 CET 2013


Rick Johnson wrote:

> When reading over some source code we really have no idea in which
> namespace a variable lives. Consider the following:
> 
> count = 0
> class Blah:
>     def meth():
>         for x in range(100):
>             count = x
> 
> Where is count living?
> 
> Of course in this simplistic example we can see that count is @ module
> level

But it isn't. It is a local variable.

Rick, I appreciate your honesty in telling us that you have no idea how to
read Python code and recognise which namespace the variables are found in,
but you really shouldn't assume others suffer under that same affliction.



-- 
Steven




More information about the Python-list mailing list