[Python-3000] The meaning of "global variable"
Talin
talin at acm.org
Fri Nov 3 03:42:02 CET 2006
Greg Ewing wrote:
> Ka-Ping Yee wrote:
>> Before it is reasonable to change the meaning of "global", we would
>> need to have coherent answers to these questions:
>>
>> 1. What is the global namespace?
>
> Under the proposal, there is no such thing as
> "the" global namespace, so the question is
> meaningless.
>
> There's no such thing now, either -- there
> are just (multiple) module-level namespaces.
I think that the argument that "there's no such thing as a global
namespace, either now or in the future" are using an overly pedantic
definition of the word "global".
In Python "global" means, and has always meant, the namespace of the
current module. It is the namespace that is "outside of any function
definition", and that is true regardless of which module we are talking
about. It is a "special" namespace because it has different semantics
than the namespaces that are defined within a function scope.
You can't just hand-wave this away - the 'global' namespace is far too
important and useful to be just dismissed out of hand.
I think the confusion stems from the fact that in many contexts, the
word 'global' is a synonym for 'universal'. However, there's more than
one planet in the universe...and no one is arguing that global variables
in Python are in any way 'universal' variables.
-- Talin
More information about the Python-3000
mailing list