Tag Archives: name

How to get class method name in Python?

There are two ways to do this. You can either do: def whoami(): “””Returns name of the method.””” import sys return sys._getframe(1).f_code.co_name def callersname(): “””Returns name of the caller.””” import sys return sys._getframe(2).f_code.co_name Or you can simply do: import inspect … Continue reading

Posted in Coding, Programming, Python | Tagged , , | Leave a comment