Parametrized inheritance

Dan Bullok myfirstname at mylastname.com
Sun Jan 4 00:47:04 EST 2004


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?





More information about the Python-list mailing list