Re: introspection inquiry

2005-02-20 Thread Michael Hoffman
Robin Becker wrote: import inspect class A: _class_name=inspect.currentframe().f_code.co_name def __init__(self,text,_defining_class_name=_class_name): print 'text=',text,'_defining_class_name=',_defining_class_name class B(A): pass b=B('aaa') That won't work, if you, say, wanted to print

Re: introspection inquiry

2005-02-20 Thread Robin Becker
Michael Hoffman wrote: Robin Becker wrote: self.__class__.__name__ 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. Here's a way to do that using metacla

Re: introspection inquiry

2005-02-20 Thread Michael Hoffman
John Roth wrote: If that's the case, then the inspect module should give the tools to do it without a great deal of angst. Unfortunately, it doesn't give you the class that defined the method, just the class that invoked it. Are you saying that the inspect module *should* give you the tools to do i

Re: introspection inquiry

2005-02-20 Thread Michael Hoffman
Diez B. Roggisch wrote: >[Michael Hoffman]: 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 - a

Re: introspection inquiry

2005-02-20 Thread John Roth
"Michael Hoffman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Robin Becker wrote: self.__class__.__name__ 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 metho

Re: introspection inquiry

2005-02-20 Thread Diez B. Roggisch
> 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 c

Re: introspection inquiry

2005-02-20 Thread Michael Hoffman
Robin Becker wrote: self.__class__.__name__ 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. Here's a way to do that using metaclasses and Python's magic

Re: introspection inquiry

2005-02-20 Thread Robin Becker
[EMAIL PROTECTED] wrote: ... My question is this: what can be substituted for that will make the example above work? self.__class__.__name__ -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list