[Python-ideas] add variable "__this_func__" inside all functions' locals
ryan at ryanhiebert.com
Tue Feb 28 21:54:14 EST 2017
> On Feb 28, 2017, at 8:14 PM, 语言破碎处 <mlet_it_bew at 126.com> wrote:
> We need not care other functions, just the "current" one.
> Other functions are definitely out of our control.
> My last example distinguish 3 cases:
> self.f() # object/overloaded version
> __class__.f(self) # decorated version
> __this_func__(self) # prime version
If your decorator uses `functools.wraps` or `functools.update_wrapper` (it should, for lots of reasons, and many, perhaps most, third party wrappers do), then you can access the wrapped function as `decorated.__wrapped__`.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas