Needed: Real-world examples for Python's Cooperative Multiple Inheritance

Alice Bevan–McGregor alice at gothcandy.com
Thu Nov 25 00:16:14 EST 2010


On 2010-11-24 12:08:04 -0800, Raymond Hettinger said:

> 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 
> inheritance.

The SocketServer module 
(http://docs.python.org/library/socketserver.html) uses cooperative 
multiple inheritance to implement threading / async using a 
ThreadingMixIn class and multi-processing using a ForkingMixIn class, 
which may not be as complicated a use case as you are looking for.

One thing that caught me up was the attribute resolution order; it's a 
FIFO, with the first superclass being examined preferentially over 
later superclasses in the declaration.  (Mixins go before the class 
they extend.)

 — Alice.




More information about the Python-list mailing list