How to get current function into a variable?

How can I get a variable that contains the currently executing function in Python? I don’t want the function’s name. I know I can use inspect.stack to get the current function name. I want the actual callable object. Can this be done without using inspect.stack to retrieve the function’s name and then evaling the name to get the callable object?

What’s the biggest difference between dir() and __dict__ in Python

class C(object): def f(self): print self.__dict__ print dir(self) c = C() c.f() output: {} ['__class__', '__delattr__','f',….] why there is not a ‘f’ in self.__dict__ Answers: Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If … Read more