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

Talin talin at acm.org
Tue Jul 11 08:05:19 CEST 2006


Ka-Ping Yee wrote:
> On Mon, 10 Jul 2006 skip at pobox.com wrote:
> 
>>I think Talin's got a point though.  It seems hard to find one short English
>>word that captures the essence of the desired behavior.  None of the words
>>in his list seem strongly suggestive of the meaning to me.  I suspect that
>>means one's ultimately as good (or as bad) as the rest.
> 
> 
> What's wrong with "nonlocal"?  I don't think i've seen an argument
> against that one so far (from Talin or others).

Well, I just think that a fix for "an aesthetic wart" should be, well, 
aesthetic :)

I also think that it won't be a complete disaster if we do nothing at 
all - there *are* existing ways to deal with this problem; there are 
even some which aren't hackish and non-obvious. For example, its easy 
enough to create an object which acts as an artificial scope:

    def x():
       scope = object()
       scope.x = 1
       def y():
          scope.x = 2

To my mind, the above code looks about as elegant and efficient as most 
of the proposals put forward so far, and it already works.

How much are we really saving here by building this feature into the 
language?

-- Talin


More information about the Python-Dev mailing list