[Python-3000] Draft PEP for outer scopes

Georg Brandl g.brandl at gmx.net
Thu Nov 2 17:09:26 CET 2006


Jan Grant wrote:
> On Wed, 1 Nov 2006, Steven Bethard wrote:
> 
>> I don't think that'll really be worth it.  I'd be amazed if people
>> didn't expect it to mean "top-level". The real question is, if people
>> see something like this::
>> 
>>     def f():
>>         n = 0
>>         def g(i):
>>             global n
>>             n += i
>>         return g
>>     func = f()
>>     print func(), func()
>> 
>> what would they expect it to do?
> 
> Set "n" in the scope of "func", assuming func is top-level. That global 
> is already a lie isn't a feature.
> 
> I'd rather see "outer" than "global" but even that can be understood to 
> mean "outermost" rather than "the next one out".
> 
> jan
> 
> PS. If you're hunting for keywords to overload to drag variables into scope, 
> "import" is also available, although would probably be very hard to make 
> work.

How should that possibly work?

Georg



More information about the Python-3000 mailing list