introspection inquiry

John Roth newsgroups at jhrothjr.com
Sun Feb 20 10:47:48 EST 2005


"Michael Hoffman" <cam.ac.uk at mh391.invalid> wrote in message 
news:cvaaae$77q$1 at gemini.csx.cam.ac.uk...
> 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.

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.

John Roth





More information about the Python-list mailing list