What is the class of myobj?

JXStern JXSternChangeX2R at gte.net
Wed Oct 16 11:00:44 EDT 2002


On Wed, 16 Oct 2002 11:29:57 +0100, Xiao-Qin Xia <xx758 at cam.ac.uk>
wrote:
>Class MyClass: pass
>myobj = MyClass()
>if myobj.__class__.__name__ == "MyClass": print "OK!"
>if myobj.__class__ == MyClass: print "OK!"

Also very useful to know, thanks!

Especially that last one never occured to me, eg:

>print MyClass
__main__.MyClass

J.






More information about the Python-list mailing list