Needed: Real-world examples for Python's Cooperative Multiple Inheritance
no.email at nospam.invalid
Fri Nov 26 00:34:33 CET 2010
Raymond Hettinger <python at rcn.com> writes:
> I'm writing-up more guidance on how to use super() and would like to
> point at some real-world Python examples of cooperative multiple
I'd mention the SocketServer library, except I'm not sure what you
mean by "cooperative", so I don't know if that counts.
The few times I've tried to use multiple inheritance, I think it wasn't
the right idea for what I was doing. It turns into a big mess quite
The classic example though is a window system, where you have a "window"
class, and a "scroll bar" class, and a "drop-down menu" class, etc. and
if you want a window with a scroll bar and a drop-down menu, you inherit
from all three of those classes. They each have to support (e.g.) a
"redraw" operation, so automatic method combination figures out what to
I''ve mostly seen this stuff in connection with Lisp. If you look at a
CLOS manual you can probably find examples. There are also some
examples in the old CADR manual, using the MIT Flavors system which
predated CLOS. That manual is online now:
The object system is documented in this chapter:
The paragraph about "defwrapper" gives a clear view into the machinery.
More information about the Python-list