Python recipes: list mixin, improved timeit, etc

barnesc at engr.orst.edu barnesc at engr.orst.edu
Fri Oct 7 09:11:35 EDT 2005


>So mixins are just a sub-class [pun intended] of sub-classing?
>
>I've just found this:
>
>[quote]
>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]
>
>from http://c2.com/cgi/wiki?MixIn
>
>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...
>
>*wink*
>

"A mixin is an atomic unit in an object-oriented language that adds
functionality to another class."

 - http://www.macromedia.com/support/documentation/en/flex/1/mixin/
   mixin2.html#118542

The only experience I've had with mixins is in Python, where
UserDict has a class DictMixin that defines the full dictionary
interface from a minimal subset of dictionary methods.

The Python docs don't define mixin.  I just assumed this was a case
where a programmer needed a name more descriptive than foo, so he
called it mixin, and that stuck.  :)

 - Connelly Barnes



More information about the Python-list mailing list