print type(someObject).__name__
If that doesn't suit you, use this:
print some_instance.__class__.__name__
Example:
class A:
pass
print type(A())
# prints <type 'instance'>
print A().__class__.__name__
# prints A
Also, it seems there are differences with type()
when using new-style classes vs old-style (that is, inheritance from object
). For a new-style class, type(someObject).__name__
returns the name, and for old-style classes it returns instance
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…