Python Mixins
Duncan Booth
duncan.booth at invalid.invalid
Fri Sep 23 05:19:09 EDT 2011
Matt <mattj.morrison at gmail.com> wrote:
> I'm curious about what people's opinions are about using mixins in
> Python. I really like, for example, the way that class based views
> were implemented in Django 1.3 using mixins. It makes everything
> extremely customizable and reusable. I think this is a very good
> practice to follow, however, in Python mixins are achieved by using
> (or perhaps misusing) inheritance and often multiple inheritance.
>
I think Mixins are great, in moderation, but wait until you have to debug
code on an object with 70 base classes.
Reinout van Rees wrote a very insightful article recently about Django's
use of multiple inheritance:
http://reinout.vanrees.org/weblog/2011/08/23/class-based-views.html
He points out the problems that arise from overuse of mixins; why Zope went
through so much upheaval to get away from mixins everywhere and switched to
a component architecture instead; and suggests that Django will do the same
in a few years time.
--
Duncan Booth http://kupuguy.blogspot.com
More information about the Python-list
mailing list