Mixin classes and single/multiple inheritance

Michele Simionato michele.simionato at gmail.com
Thu Sep 20 00:30:07 EDT 2007


On Sep 20, 5:41 am, Ben Finney <bignose+hates-s... at benfinney.id.au>
wrote:
> Okay. How do we use the language we have to achieve what mixin classes
> achieve in Ruby? Can you give an code example that you *would*
> recommend for someone looking to do what mixin classes do?

Since the language we have does have multiple inheritance, let's
use it to implement mixins. My point was that even if Python had
been implemented without multiple inheritance, it would have
been simple to implement mixins, or by copying the methods,
or by dispatching with __getattr__. So, multiple inheritance
is giving us very little for the point of view of mixins; OTOH,
multiple inheritance is giving us a lot of headaches for
what concerns cooperative methods.

    Michele Simionato




More information about the Python-list mailing list