20 Mar
2012
20 Mar
'12
2:47 p.m.
Whoops, cut and paste error. The code should have read:
def f_with_new_closure(f, closure): return types.FunctionType(f.__code__, f.__globals__, f.__name__, f.__defaults__, closure)
def modifier(func, closure): if func.__wrapped__: while func.__wrapped__.__wrapped__: func = func.__wrapped__ func.__wrapped__ = f_with_new_closure(func.__wrapped__, closure) return func else: return f_with_new_closure(func, closure)
Cheers, Mark.