[IPython-dev] 'Unwrapping' decorated functions in IPython

Thomas Kluyver takowl at gmail.com
Fri Jul 15 07:13:50 EDT 2011


Hi Michele,

Ben's been working on getting IPython's "func??" introspection to
automatically unwrap functions decorated with @decorator. (
https://github.com/ipython/ipython/pull/578 )

If a function is wrapped in several layers, f.__wrapped__ refers to the
object one level below. This is in contrast to Python 3 functools.wraps,
which seems to point __wrapped__ to the original function from any wrapping
layer. Of course, we could unwrap repeatedly in a while loop, but I'm
reluctant to do this in case strange objects from other packages drop it
into an infinite loop.

Would you consider making __wrapped__ (or another similar attribute) point
to the original function when several layers of wrapping are present? Or do
you know of a better way to approach the problem?

Thanks,
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20110715/49df737c/attachment.html>


More information about the IPython-dev mailing list