class object def foo self print self __class__ __name__ print inspect

1
2
3
4
5
6
7
8
9
>>> class A(object):
... def foo(self):
... print self.__class__.__name__
... print inspect.getframeinfo(inspect.currentframe())[2]
...
>>> a = A()
>>> a.foo()
A
foo