Introspection Class/Instance Name

wittempj@hotmail.com martin.witte at gmail.com
Wed Apr 26 03:42:20 EDT 2006


What about:

py> class A:
py.     def __init__(self):
py.             print self.__class__.__name__
py.             print str(self)
py.     def __str__(self):
py.             return 'instance of %s' % self.__class__.__name__
py. 
py> a = A()
A
instance of A
py>




More information about the Python-list mailing list