I will probably miss something simple. Given an instance of a class, I would like to get only the class name. For instance:
class Foooo: pass instance = Foooo() print("instance.__class__ = "+str(instance.__class__)) print("Just the class name: "+str(instance.__class__).split(".")[-1][:-2])
This gives the following result:
instance.__class__ = <class '__main__.Foooo'> Just the class name: Foooo
Is there something simpler than
str(instance.__class__).split(".")[-1][:-2]?
I'm in Python 3.2 if this helps ...
source share