On 10/11/2013 12:36 AM, Steven D'Aprano wrote:

I also like Terry Reedy's suggestion of having the decorator
automatically add the unwrapped function to the wrapped function as an
attribute:

def decorate(func):
     @functools.wraps(func)
     def inner(arg):
         blah blah
     inner._unwrapped = func  # make it public if you prefer
     return inner

which makes it all nice and clean and above board. (I seem to recall a
proposal to have functools.wraps do this automatically...)

The explicit attribute can also be set by class rather than closure based decorators.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to