PyWart: Namespace asinitiy and the folly of the global statement

Chris Angelico rosuav at
Fri Feb 8 07:25:34 CET 2013

On Fri, Feb 8, 2013 at 3:30 PM, Rick Johnson
<rantingrickjohnson at> wrote:
> It is my strong opinion that all "unqualified" variables must be local to the containing block, func/meth, class, or module. To access any variable outside of the local scope a programmer MUST qualify that variable with the func, class, or module identifiers. Consider the following examples

Okay. Now start actually working with things, instead of just making
toys. All your builtins now need to be qualified:

are",__builtins__.len(self.some_list),"members in this list,

And your imports happen at module level, so they need extra qualification:

# file:

import sys

def foo():
    __builtins__.print("My args were:",example.sys.argv)

Actually, you already ran up against this. Your example needs to become:

for x in __builtins__.range(100):
    # Increment the module level variable count.
    example.count += 1

Or are you going to make builtins and imports magically available as
PHP-style superglobals?


More information about the Python-list mailing list