Getting class name

Eric Brunel eric.brunel at pragmadev.com
Fri Aug 29 11:58:18 EDT 2003


Travis Whitton wrote:
> 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
> 
> Basically, I'm using WebWare, and I need to pass the current servlet name
> to a template. I don't want to have to hardcode the classname inside of
> every servlet.

print self.__class__.__name__

HTH
-- 
- Eric Brunel <eric.brunel at pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com





More information about the Python-list mailing list