[Python-ideas] Tweaking closures and lexical scoping to include the function being defined
him at online.de
Thu Sep 29 17:31:16 CEST 2011
On 29/09/2011 17:21, Ethan Furman wrote:
> Paul Moore wrote:
>> Actually, while we're using keywords as decorator names,
>> @with(n=0, lock=threading.Lock())
>> def global_counter():
>> with lock:
>> n += 1
>> return n
>> reads well to me, and avoids the technical/jargon word "nonlocal".
> I think 'nonlocal' is the better choice as it mirrors what nonlocal
> does inside the function. Because of its current usage 'with' will
> generate questions about __enter__ and __exit__.
But what if the decorator is used inside an outer function? Wouldn't
that be confusing?
What about @func_attrs(...) ? - it would give a hint where the objects
are actually located.
More information about the Python-ideas