[Python-ideas] make __closure__ writable

Mark Shannon mark at hotpy.org
Tue Mar 20 15:47:03 CET 2012


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.


More information about the Python-ideas mailing list

AltStyle によって変換されたページ (->オリジナル) /