
Oct. 21, 2003
11:06 p.m.
Guido van Rossum wrote:
[...] Maybe "global x in f" would work?
def outer(): x = 1 def intermediate(): x = 2 def inner(): global x in outer x = 42 inner() print x # prints 2 intermediate() print x # prints 42
Why not make local variables attributes of the function, i.e. replace: def inner(): global x in outer x = 42 with: def inner(): outer.x = 42 Global variables could then be assigned via: global.x = 42 Could this be made backwards compatible? Bye, Walter Dörwald