[Python-ideas] Access to function objects

Nick Coghlan ncoghlan at gmail.com
Wed Aug 10 09:09:57 CEST 2011

On Wed, Aug 10, 2011 at 2:47 PM, Ben Finney <ben+python at benfinney.id.au> wrote:
> Guido van Rossum <guido at python.org> writes:
>> It seems that your problem is how to get to the function object
>> underneath the stack of decorators given an object that is the
>> fully-decorated function. Never mind then.
> Yes. I'd still like a solution to that.

The thing is that there isn't a general purpose way to resolve that
question. Consider a wrapper like functools.lru_cache. It has 3
downcalls to other functions: tuple, sorted and the decorated user
function. Without an explicit convention (like the __wrapped__
convention adopted by functools in 3.2), there's no way for external
code to follow the chain downwards.


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list