I forget it every time, so make a note.
sys._getframe().f_code.co_name
Write a simple function and give it a try.
>>> def printFuncName():
... print sys._getframe().f_code.co_name
...
>>> printFuncName()
printFuncName
I often use it in such situations.
from abc import abstractmethod
class SuperClass(object):
@abstractmethod
def implementMe():
raise NotImplementedError( sys._getframe().f_code.co_name )
Recommended Posts