Needed: Real-world examples for Python's Cooperative Multiple Inheritance
raymond.activestate at gmail.com
Fri Nov 26 02:36:43 CET 2010
On Nov 25, 3:38 pm, John Nagle <na... at animats.com> wrote:
> Multiple inheritance in Python is basically what fell out of
> CPython's internals, not a design.
Sorry to disagree. That is historically inaccurate.
Guido designed super() on purpose. He took his cues from
"Putting Metaclasses to Work" by Ira Forman and Scott Danforth.
The method resolution order was based on yet another paper
which showed the defects in the two earlier designs for
It may not be great, but it sure wasn't an accident.
> Best practice for this is "don't do it." Some name clashes ought
> to simply be detected as errors, rather than being given such
> complex semantics.
That may well be true. If a coder has enough control over the classes
to be make sure they use super() in a way that supports cooperative
multiple inheritance, then they have enough control to just
rename the methods to prevent name diamond shaped name clashes.
OTOH, sometimes you don't have control over the names if they
are magic methods or standard names like close(), save(), flush(),
More information about the Python-list