[Python-Dev] Re: let's not stretch a keyword's use unreasonably, _please_...

Guido van Rossum guido at python.org
Thu Oct 23 13:04:16 EDT 2003

>     >>> import __main__ as m # I know, not general, just for trial
>     >>> m.c=3
> Isn't (in 3.0) the notion of being able to modify another module's globals
> supposed to get restricted to help out (among other things) the compiler?
> If so, this use, even though it's not really modifying a global in another
> module, might not work forever.

That's one reason why I'd rather continue to use 'global' than some
attribute assignment.  To the compiler, module globals are more
special than class variables etc. because they can shadow builtins.
Therefore the compiler would like to know about *all* assignments to
module globals.

Similarly, assignment to locals in outer scopes need to be known to
the compiler because it must make sure that all locals referenced by
inner scopes are implemented as cells.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list