Parametrized inheritance

Aahz aahz at pythoncraft.com
Sun Jan 4 11:13:39 EST 2004


In article <sNNJb.741891$Fm2.670283 at attbi_s04>,
Dan Bullok  <myfirstname at mylastname.com> wrote:
>Mike C. Fletcher wrote:
>>
>> You can find more information about these kinds of patterns by searching
>> for "Mix-In Class" and/or "Multiple Inheritance".  Python 2.2 changed how
>> multiple inheritance graphs are constructed in Python, BTW.  If you used
>> old-style classes the mro would have been [MySub, Sub, Base, MyBase, Base]
>> IIRC.
>
>Well, I thought of doing this, but after looking up resolution order (sec
>9.5.1 of the tutorial) I found that resolution is done "depth-first,
>left-to-right",  In my example, that would have given [MySub, Sub, Base,
>MyBase, Base], but, I checked, using mro(), and found that it was indeed
>[MySub, Sub, MyBase, Base], just as I needed it.  (thanks for the mro() tip
>- didn't know about that one).  Unless I've gone crosseyed (possible, it's
>late), this is NOT depth-first, left-to-right.  So is the tutorial out of
>date?

As Mike said, it's different for new-style classes.  See
http://www.python.org/2.2.3/descrintro.html
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Weinberg's Second Law: If builders built buildings the way programmers wrote 
programs, then the first woodpecker that came along would destroy civilization.



More information about the Python-list mailing list