introspection inquiry
Diez B. Roggisch
deetsNOSPAM at web.de
Sun Feb 20 10:47:38 EST 2005
> Unless I misunderstood the question, that won't work. That will
> give you the name of the class the object is an instance is of.
> I think he wants the name of the class the method was defined in.
Where is the difference? The method is defined in a class - and an instance
is created from that class.
This works as expected:
class ExistentialCrisis:
def __init__(self, text):
self.spam = text
print 'In the constructor of the %s class' % self.__class__.__name__
ExistentialCrisis("egal")
--
Regards,
Diez B. Roggisch
More information about the Python-list
mailing list