How do I find out a name of class that created an instance of an object in Python if the function I am doing this from is the base class of which the class of the instance h
Alternatively you can use the classmethod decorator:
classmethod
class A: @classmethod def get_classname(cls): return cls.__name__ def use_classname(self): return self.get_classname()
Usage:
>>> A.get_classname() 'A' >>> a = A() >>> a.get_classname() 'A' >>> a.use_classname() 'A'