Over(joy)riding

Kurt Smith kwmsmith at gmail.com
Wed Feb 17 11:00:23 EST 2010


On Wed, Feb 17, 2010 at 9:08 AM, mk <mrkafk at gmail.com> wrote:
> Bruno Desthuilliers wrote:
>>
>> mk a écrit :
>>>
>>> P.S. Method resolution order in Python makes me want to kill small
>>> kittens.
>>
>> mro is only a "problem" when using MI.
>
> Oh sure! And I have the impression that multiple inheritance is not used all
> that often. What (some) Python code I've read in open source projects
> typically uses single inheritance.
>
> Nevertheless MI is there in Python, might be useful in some cases and Guido
> put it there for some reason, so Citizens Aspiring To Become Pythonistas
> like me work to learn it.

In case you're not familiar with it, MI allows you to have mixins &
traits.  They work very well if the mixin superclasses don't have any
clashes with the other superclasses, so each mixin adds its own unique
set of methods to the derived class.  Then you don't have to worry
about mro and all that (at least as much).

Here's an article on it, with examples:

http://www.linuxjournal.com/node/4540/print

Michele Simionato has some criticism of MI pitfalls and has come up
with the straits module to remedy it -- you might be interested.  He
goes into detail here:

http://www.artima.com/weblogs/viewpost.jsp?thread=246488

Kurt



More information about the Python-list mailing list