[Python-ideas] Allow lambda decorators

Arnaud Delobelle arnodel at googlemail.com
Tue Feb 10 08:15:55 CET 2009


On 10 Feb 2009, at 05:25, Greg Ewing wrote:

> Arnaud Delobelle wrote:
>
>> Cool! I'll be able to introduce a new scope at the drop of a hat with
>> a new handy 'idiom':
>> def foo(x):
>>    a = x + 1
>>    for new a in a**2,:
>>        print a
>>    print a
>
> Before you get too carried away with that, I'd like
> to make it clear that in my version of the semantics
> of 'new', it *not* work that way -- 'a' would remain
> bound to the last cell, and therefore the last value,
> that it was given by the for-loop.
>
> I considered that a feature of my proposal, i.e. it
> preserves the ability to use the loop variable's value
> after exiting the loop, which some people seem to like.

Sorry I should have made it clearer that my 'idiom' was tongue in cheek.
Indeed I think that it's better to let the value of the inner 'a'  
spill outside the loop.

-- 
Arnaud




More information about the Python-ideas mailing list