30 Sep
2011
30 Sep
'11
3:45 a.m.
On Sep 29, 2011, at 5:35 PM, Ron Adam wrote:
@set_closure(x=0) def adder(y): nonlocal x x += y return x
Won't work as written because the nonlocal will cause an error before the decorator is applied. The other day, I suggested we add the ability for decorators to have a __prepare__ method that creates the namespace the function being created will use, but it was shot down as impractical. It would however do what you want to do here.