[Zope-dev] Is there a way to find out where a method is defined?

Andrew Wilcox circle@gwi.net
Sat, 05 Feb 2000 09:55:07 -0500


While browsing through Zope and product Python source code, I often see a
method being called on an object and want to find out what it's doing and
look up the definition.  Because Zope objects often have many superclasses,
I end up scanning through many class definitions.  (My most recent
experience was finally finding the definition of this() in the Item class,
and saying, oh yes, that's correct, it doesn't do anything :-)

And, there's always a danger that I'll miss a definition in a subclass or a
superclass that gets inherited first, and be looking at the wrong method
definition for the particular object.

Is there a way in the runtime or in the debugger, perhaps through the magic
of Python reflection, to ask "when I call this method on this object, this
is the class providing the definition?"