[Python-ideas] make __closure__ writable
yselivanov.ml at gmail.com
Fri Mar 16 19:57:47 CET 2012
Decorators can be nested, and what you can do in this case is to
find the most inner-wrapped function by traversing the '__wrapped__'
attributes (and check that the function you found is the actual
original function). After that you can play with its attributes,
but you can't simply substitute the function object, as the inner
decorator won't use it. So sometimes you have to work with the
function object without a way of substituting it.
On 2012-03-16, at 2:37 PM, Mark Shannon wrote:
> Yury Selivanov wrote:
>> Can we make the __closure__ attribute writeable? Since __code__ already is,
>> and it is possible to tackle with the opcodes, having no way of rewriting __closure__ (except creating a completely new function) is annoying.
> What's wrong with using a decorator?
>> I don't think it will somehow harm python, as those who want to break it can
>> do it already in multiple ways, easier than playing with __closure__.
>> Python-ideas mailing list
>> Python-ideas at python.org
> Python-ideas mailing list
> Python-ideas at python.org
More information about the Python-ideas