"Paolino" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > [EMAIL PROTECTED] wrote: > I don't think the global keyword is useful actually. > What's so special in a module nemespace to be priviledged like that.
The specialness of globals and locals was part of Python's original simple namespace design, and is still reflected in exec statements and eval functions, as well as in nested functions. > The point IMO is accessing names defined somewhere in the enclosing > namespaces. Accessing such names is already possible, even *after* the outer function returns and the rest of its execution context is deleted. > def enclosing(): > var=2 > def enclosed(): > outer var=4 This is rebinding, rather than merely accessing. Similar, but even more problematical would be initial binding in outer from inner: def enclosing(): def enclosed(): outer var = 4 > this is the base of something useful. Actually, it is the reinvention of classes: class enclosing(object): def __init__(self): self.var = 2 def enclosed(self): self.var = 4 There was a long discussion on the pydev list a couple of years ago re adding rebinding in addition to access (of outer variables). I think, in the end, Guido concluded that there was no compelling reason, as of then, to add another general mechanism for private, sharable, rebindable variables. > I think there is only one or none possible solution to an outer statement There were lots of proposals for both the exact syntax and semantics of outer binding/rebinding. Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list