Cameron Simpson <c...@zip.com.au> writes:

> On 11Oct2013 02:55, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> 
> wrote:
> > def undecorate(f):
> >     """Return the undecorated inner function from function f."""
> >     return f.func_closure[0].cell_contents
>
> Whereas this feels like black magic. Is this portable to any decorated
> function? If so, I'd have hoped it was in the stdlib. If not: black
> magic.

What would you expect? The purpose of decorating functions is to do
magic to make it appear as though the original function isn't there any
more. Any technique to getting at that original function anyway is *of
course* going to look like black magic at the implementation level.

-- 
 \        “What if the Hokey Pokey IS what it's all about?” —anonymous |
  `\                                                                   |
_o__)                                                                  |
Ben Finney

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

Reply via email to