On 11Oct2013 14:42, Ben Finney <ben+pyt...@benfinney.id.au> wrote: > 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.
Sigh. Yes of course. It is no uglier than walking a frame stack etc. But is it reliable? Will it work on any decorated function? If so, fine, and I'd be happy to squirrel it away as a useful standard incantation for something. If not, then it's nasty only-mostly-reliable magic and I either want little to do with it, OR I want to know its specific limitations so I know when to use it and when not. -- Cameron Simpson <c...@zip.com.au> But pessimism IS realism! - D.L.Bahr -- https://mail.python.org/mailman/listinfo/python-list