Getting class name

Michael Hudson mwh at
Fri Aug 29 17:50:47 CEST 2003

Travis Whitton <whitton at> writes:

> Hello all,
> I've googled a bit, and I've failed to find an answer to this question. Is it
> possible to get a classes name from inside of a class? I.e.,
> class Foo:
>     def print_classname(self):
>         # somehow print Foo

print self.__class__.__name__



  MARVIN:  Do you want me to sit in a corner and rust, or just fall
           apart where I'm standing?
                    -- The Hitch-Hikers Guide to the Galaxy, Episode 2

More information about the Python-list mailing list