How to order base classes?

kj no.email at please.post
Thu Dec 23 22:36:28 EST 2010




Suppose that I want to write a subclass C of base classes A and B.
What considerations should go into choosing the ordering of A and
B in C's base class list?

Since any order one chooses can be overridden on a per-method basis,
by assigning the desired parent's method to the appropriate class
attribute, like this:

class C(B, A)
    # override methods spam, ham, and eggs from B
    spam = A.spam;
    ham = A.ham;
    eggs = A.eggs;
    ...

...it is difficult for me to see a strong compelling reason for picking
an ordering over another.  But may be just ignorance on my part.

How should one go about deciding the ordering of base classes?

TIA!

~kj



More information about the Python-list mailing list