Python recipes: list mixin, improved timeit, etc
mwm at mired.org
Fri Oct 7 14:53:06 CEST 2005
Steven D'Aprano <steve at REMOVETHIScyber.com.au> writes:
> On Thu, 06 Oct 2005 21:03:33 -0700, barnesc wrote:
>> I added some recipes to the Python Cookbook:
>> - listmixin
>> Use ListMixin to create custom list classes from a small subset of
>> list methods:
> That looks great. Now, if only I understood mixins: what are they, and
> what they are for, and in particular, how they differ from mere
One way to look at it is that mixins are a special case of
subclassing. They aren't different, just specific.
Mixins are abstract. Using Paul's example, you'd never declare a
ScrollBar object, only subclasses that also inherit from some form of
Mixins are about behavior, not type. If you have real mixins, then an
object of a class that inherits from a mixin is not an instance of the
Mixins are one way to deal with the lack of multiple inheritance. But
even languages with multiple inheritance find the idea useful.
Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list