Getting class name

T

Travis Whitton

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.

TIA,
Travis Whitton
 
M

Michael Hudson

Travis Whitton said:
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__

?

Cheers,
mwh
 
E

Eric Brunel

Travis said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top