[Python-Dev] Explicit Lexical Scoping (pre-PEP?)

Simon Percivall s.percivall at chello.se
Wed Jul 5 14:18:00 CEST 2006


I know this is very similar to the "global.x =" syntax, which
was already shot down?, but wouldn't allowing access to a
functions locals from within, by prefixing the name, be a good
way to disambiguate what happens (instead of any operator to
indicate outer scope, like .x = 3 or the like)? I guess this
necessitates "global.x =" as well, though.

def foo():
     def bar():
         foo.x = 3
     print x # prints 3

I seem to recall that this syntax has been proposed before,
though not in this discussion. But my memory is murky.

//Simon






More information about the Python-Dev mailing list