Introspect the class name of object?

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Wed Nov 21 23:03:29 EST 2007


On Wed, 21 Nov 2007 18:55:21 -0800, Davy wrote:

> Hi all,
> 
> How to get the class name of an object from an introspect way? For
> example,
> Class cls:pass
> 
> obj = cls()
> 
> I want to get function(obj) = 'cls'


obj.__class__ returns the class itself.

obj.__class__.__name__ returns the name of the class as a string.





-- 
Steven.



More information about the Python-list mailing list