class name lookup

Mark Hammond mhammond at skippinet.com.au
Thu Oct 28 19:25:54 EDT 1999


> I'm wondering if there is any better way to look up a class 
> name at run
> time than what I've come up with this far. I wan't to retrieve the
> instance class name from within base class.

Sure is:

>     print 'class name = ', str(self)   # or repr(self)
Change this to"
      print 'class name = ', self.__class__.__name__

Mark.





More information about the Python-list mailing list