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

Oren Tirosh oren-py-d at hishome.net
Fri Oct 24 14:26:29 EDT 2003


On Wed, Oct 22, 2003 at 09:11:37AM -0700, Alex Martelli wrote:
...
> Alternatively, assigning to an attribute of some particular
> object still feels a better approach to me -- no new kwd,
> no stretching of bad old ones, actually a chance to let bad
> old 'global' fade slowly into the sunset.  If there's any
> chance to salvage THAT approach -- if it only needs a good
> neat syntax to get that "particular object" -- I'll be glad
> to participate in brainstorming to find it.  

How about using the word 'global' to get the current module object?
A precedent for this is None which is on its way to becoming a keyword 
to get that "particular object". 

A bit of parser magic would be required so global can still work
as a declaration for compatibility.

>>> global is sys.modules[__name__]
True
>>> global.__dict__ is globals()
True

    Oren



More information about the Python-Dev mailing list