Python recipes: list mixin, improved timeit, etc

Steven D'Aprano steve at
Fri Oct 7 15:11:56 CEST 2005

On Fri, 07 Oct 2005 05:11:00 -0700, Michele Simionato wrote:

> Well, suppose you have a class MyObject and you want to add to it some
> methods to make its instances into a database. You could put these
> methods into another class called Storable (the mixin class).
> Then you can mix MyObject with Storable and get what you want,
> a class StorableObject inheriting both from Storable and MyObject.
> Of course you can reuse Storable to make storable even other
> classes, for  instance you could define a StorableOtherObject
> inheriting from OtherObject and Storable.

So mixins are just a sub-class [pun intended] of sub-classing?

I've just found this:

A mixin class is a parent class that is inherited from - but not as
a means of specialization. Typically, the mixin will export services to a
child class, but no semantics will be implied about the child "being a
kind of" the parent.
[end quote]


Is that all they are?

It is amazing how you can take the simplest concept, and by using
appropriate terminology, make it as confusing and opaque as you want...



More information about the Python-list mailing list