[Python-Dev] Problems with the new super()

Greg Ewing greg.ewing at canterbury.ac.nz
Fri May 2 07:54:14 CEST 2008


Jared Flatow wrote:
> 
> I agree that if your methods are 'clashing' then you are  
> probably misinheriting, but cooperative methods can be the most  natural 
> way to model certain situations.

I'm not saying that nobody should ever use super, only
that it's not the right thing for the situation I was
talking about there.

What it essentially comes down to is that classes mix
well if they were designed to mix well. Keeping their
features independent is one way to achieve that.
Designing their methods to fit together in a super
call chain is another, if you can manage to pull it
off.

All I was really trying to say is that stating that
"multiple inheritance is bad" is far too simplistic.

> Is it an issue of feasibility, or of what is the 'most obvious' solution?

I can only speak from my own experience, which is that
whenever I've had a problem involving multiple inheritance,
super() didn't solve it. What did solve it was either
refactoring so that the classes being mixed were more
independent, or finding another solution that didn't
require multiple inheritance.

Usually the new solution turned out to be better in
other ways as well, so I've come to regard multiple
inheritance issues as a code smell suggesting that
I need to rethink something.

-- 
Greg



More information about the Python-Dev mailing list