Message220863
>>> def decorator(f):
... @functools.wraps(f)
... def new_func(self, junk):
... stack = inspect.stack()
... for i, frame in enumerate(stack):
... print("%s" % frame[3])
... f(self, junk)
... return new_func
...
>>> @decorator
... def junk(self, p):
... print("%s" % junk.__name__)
...
>>> junk("a", "b")
new_func
<module>
junk
>>> junk.__name__
'junk'
Note that the wrapper function itself inspects the stack, printing out the names of methods on the stack.
Note that "junk", the name of the wrapped function does not appear on the stack, it is only printed out by the junk method itself.
I think that the name of the function at the top of the stack should be the name of the wrapped function, not of its wrapper. The name of the wrapper function should not appear at all. |
|
Date |
User |
Action |
Args |
2014-06-17 19:12:26 | the.mulhern | set | recipients:
+ the.mulhern |
2014-06-17 19:12:26 | the.mulhern | set | messageid: <1403032346.55.0.812128446286.issue21794@psf.upfronthosting.co.za> |
2014-06-17 19:12:26 | the.mulhern | link | issue21794 messages |
2014-06-17 19:12:26 | the.mulhern | create | |
|