471,357 Members | 1,205 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,357 software developers and data experts.

Introspect the class name of object?

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'

Best regards,
Davy
Nov 22 '07 #1
1 12913
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.
Nov 22 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Brian Jones | last post: by
21 posts views Thread by Jon Slaughter | last post: by
14 posts views Thread by Lee Franke | last post: by
5 posts views Thread by Joe Van Dyk | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.