
Sept. 29, 2011
8:20 a.m.
On 2011-09-29, at 17:15 , 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". Let the @keyword floodgates open :-)
The problem with that one is that it's going to be read in light of the corresponding keyword, so it'd make people think the purpose is to __enter__/__exit__ all objects provided around the function call somehow (pretty nice for the lock, nonsensical for the integer, of course).