
Sept. 29, 2011
3:21 p.m.
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__. ~Ethan~