Raymond Hettinger wrote:
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.

Don't know if you are still looking for examples, but I recently came across a thread in Python-Dev which had an example using unittest:

Ricardo Kirkner wrote [much snippage]:
> I'll give you the example I came upon:
>
> I have a TestCase class, which inherits from both Django's TestCase
> and from some custom TestCases that act as mixin classes. So I have
> something like
>
> class MyTestCase(TestCase, Mixin1, Mixin2):
>    ...
>
> Since I explicitely base off 3 classes, I expected all 3
> classes to be initialized, and I expect the setUp method to be called
> on all of them.

As written this example failed because TestCase (from django) was based on unittest2.TestCase, which was not calling super. I understand, however, that if the mixins were listed before TestCase that it would work.

Hope this helps.

~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to