Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #4641
| Date | 2011-05-04 11:36 -0700 |
|---|---|
| From | Ethan Furman <ethan@stoneleaf.us> |
| Subject | Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance |
| References | <89b6d53f-dcdc-4442-957f-1f4d29115a26@n32g2000pre.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1163.1304533517.9059.python-list@python.org> (permalink) |
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~
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
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
csiph-web