[Zope-dev] Re: New-style ExtensionClasses (Zope 2.8) -- MRO issue

Dieter Maurer dieter at handshake.de
Tue Nov 25 14:44:33 EST 2003


Jeremy Hylton wrote at 2003-11-24 14:06 -0500:
 > ...
 > One of the key properties of C3 is local order is honored.  If
 > a class A has two base classes B and C, then a method defined in B and C
 > (perhaps via their base classes) will be found in B first.  
 > 
 > This matches the way I think about inheritance, but not the way the old
 > algorithm works.

Are you sure?

  The old algorithm is described in the Python Language Reference:

    Class attribute references are translated to lookups in this
    dictionary, e.g., "C.x" is translated to "C.__dict__["x"]". When
    the attribute name is not found there, the attribute search
    continues in the base classes. The search is depth-first,
    left-to-right in the order of occurrence in the base class list.

  Thus, if class "B" comes before class "C" in the list of
  base classes, "B"s attributes are found in preference of "A"s attributes.

-- 
Dieter



More information about the Zope-Dev mailing list