Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #4641 > unrolled thread

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

Started byEthan Furman <ethan@stoneleaf.us>
First post2011-05-04 11:36 -0700
Last post2011-05-18 21:24 -0700
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance Ethan Furman <ethan@stoneleaf.us> - 2011-05-04 11:36 -0700
    Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance John Nagle <nagle@animats.com> - 2011-05-18 21:24 -0700

#4641 — Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance

FromEthan Furman <ethan@stoneleaf.us>
Date2011-05-04 11:36 -0700
SubjectRe: Needed: Real-world examples for Python's Cooperative Multiple Inheritance
Message-ID<mailman.1163.1304533517.9059.python-list@python.org>
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~

[toc] | [next] | [standalone]


#5760

FromJohn Nagle <nagle@animats.com>
Date2011-05-18 21:24 -0700
Message-ID<4dd49b97$0$1909$742ec2ed@news.sonic.net>
In reply to#4641
On 5/4/2011 11:36 AM, Ethan Furman wrote:
> 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.

    Multiple inheritance in Python is so badly designed that it
probably should not be used in production code.

    Generalizing multiple inheritance from a tree to a directed
acyclic graph is usually a mistake.
			
				John Nagle

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web