Finding the name of a class

Edward C. Jones edcjones at erols.com
Wed May 12 20:10:07 EDT 2004


Is there a function or method that returns the name of a class or class 
instance?

class X(object):
     pass

X.amethod() or X().amethod() should return the string "X".

X().__class__ returns "<class '__main__.X'>" which I could parse. Ugh.

Or I could use module pyclbr. Ugh**2.



More information about the Python-list mailing list