For now, I got two ways to fetch the name of the current function/method in python
Function based
>>> import inspect
>>> import sys
>>> def hello():
... print(inspect.stack()[0][3])
... print(sys._getframe( ).f_code.co_name)
...
>>> hello()
hello
hello
Class based
>>> class Hello(object):
... def hello(self):
... print(inspect.stack()[0][3])
... print(sys._getframe( ).f_code.co_name)
...
>>> obj = Hello()
>>> obj.hello()
hello
hello
Any other ways which are more easier and efficient than this?