Replacement for keyword 'global' good idea? (e.g. 'modulescope'or 'module' better?)

Paolino paolo_veronelli at
Sun Aug 7 09:26:18 CEST 2005

Terry Reedy wrote:
> "Paolino" <paolo_veronelli at> wrote in message 
> news:42F4F2D3.80804 at
>>seberino at 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
> 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
This is using some really 'featured' namespace called class to do things 
which are useful to all namespaces.So not a solution but a hack.
Also 'self' is something really away from my example.A cloned namespace 
of the class probably.
Working hard with python namespaces is hacking: probably this makes us 
masters of python, when using namespaces should be a base knowledge.

> 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.
You cut the phrase and the meaning of it.

The only one solution I'm talking about is this:
  Stated 'outer var' in a namespace, jumping out of the namespace
  we found ourselves in another namespace.
  If 'var' is bound there, that's the solution to
  the 'outer' ,if not we jump out again.If the 'var' is never found we
  can raise an UnboundOuter error probably.

Regards Paolino

Yahoo! Messenger: chiamate gratuite in tutto il mondo

More information about the Python-list mailing list