[Python-Dev] closure semantics

Walter Dörwald walter at livinglogic.de
Tue Oct 21 19:57:20 EDT 2003

Guido van Rossum wrote:

> [...]
> Walter suggested 'global.x = 23' which looks reasonable; unfortunately
> my parser can't do this without removing the existing global statement
> from the Grammar: after seeing the token 'global' it must be able to
> make a decision about whether to expand this to a global statement or
> an assignment without peeking ahead, and that's impossible.

Another idea: We could replace the function globals() with an object
that provides __call__ for backwards compatibility, but also has a
special __setattr__. Then global assignment would be 'globals.x = 23'.
Would this be possible?

    Walter Dörwald

More information about the Python-Dev mailing list