Inspecting multiple-inheritance

Andrew Dalke dalke at dalkescientific.com
Sat Apr 13 06:10:03 EDT 2002


Terry Hancock:
>I'm trying to understand a portion of Zope, which involves
>highly multiply-inherited objects.  There are several
>instances of methods being overloaded, and so I'm trying
>to figure out "who wins".
  ...
>I know I can find out what methods/attributes an object
>has by using dir() -- but is it possible to figure out
>what arguments they expect, or what superclass they
>came from?

Does this help any?

>>> class Base:
...  def add(self, i):
...   pass
...
>>> class Acid:
...  def add(self, i):
...   pass
...
>>> class Salt(Base, Acid):
...  pass
...
>>> Salt.add
<unbound method Base.add>
>>> salt = Salt()
>>> salt.add
<method Base.add of Salt instance at 1061720>
>>> salt.add.im_class
<class __main__.Base at 1060c00>
>>>

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list