[Python-3000] The meaning of "global variable"

Ka-Ping Yee python at zesty.ca
Fri Nov 3 08:50:46 CET 2006


On Fri, 3 Nov 2006, Greg Ewing 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.

Okay... tell that to all the writers of Python books and webpages
that mention "the global namespace".

Should we remove any occurrences of this phrase from the official
Python documentation as well?

> > either you have
> > to say (#1) there is no longer such a thing as "the global namespace",
>
> As I said, there isn't one now. Which namespace
> is "the global namespace" depends on which module
> you're looking from. Under the proposal, it would
> depend on which scope you're looking from.

No -- it's much worse than that.  That's the problem: even if you
know which scope you're looking from, you wouldn't be able to point
to anything and say "that's the global namespace".  If we repurpose
"global" to mean "nonlocal", the declaration "global a, b, c" might
mean that a, b, and c all belong to different namespaces.

Right now, in any given context, "the global namespace" has a clear
meaning: the namespace shared by the whole file.  With the new meaning
of the "global" keyword, "global namespace" becomes meaningless no
matter what the context.  In Python, the concepts of "global", "global
variable", and "global namespace" are too well established to destroy.


-- ?!ng


More information about the Python-3000 mailing list