Given the frame object (as returned by sys._getframe, for instance), can I get the underlying callable object?
Code explanation:
def foo(): frame = s
A little ugly but here it is:
frame.f_globals[frame.f_code.co_name]
Full example:
#!/usr/bin/env python import sys def foo(): frame = sys._getframe() x = frame.f_globals[frame.f_code.co_name] print foo is x foo()
Prints 'True'.