introspection inquiry

mirandacascade at yahoo.com mirandacascade at yahoo.com
Sun Feb 20 09:45:11 EST 2005


Where in the language would one find the intropsection capability to
answer the question: what class am I in?

Example:

class ExistentialCrisis:
    def __init__(self, text):
        self.spam = text
        print 'In the constructor of the %s class' % <whatever>

When the constructor method is invoked, would like to see the following
message:

In the constructor of the ExistentialCrisis class

and I would like to be able to do it without substituting the literal
string 'ExistentialCrisis' for <whatever>.

My question is this: what can be substituted for <whatever> that will
make the example above work?




More information about the Python-list mailing list