mix-in classes

Dr. John Q. Hacker zondervanz at gmail.com
Tue Jun 16 21:55:00 EDT 2015


On Sun, May 24, 2015 at 6:11 AM, Steven D'Aprano <steve at pearwood.info>
wrote:

> On Sun, 24 May 2015 11:53 am, Dr. John Q. Hacker wrote:
> But, frankly, what you describe is more likely to be a weakness of multiple
> inheritance and mixins, one which should be avoided. One attempt to avoid
> this problem is with traits, an alternative to mixins which explicitly
> deals with the problem of mixin conflicts.
>
> http://www.artima.com/weblogs/viewpost.jsp?thread=246488
>

Interesting.  This brings up an issue another poster brought up:  In my
usage of the term "parent", I use it to mean the class that is a product of
object composition:

class Parent(child1, child2):  pass

I figure that it is this "Parent" class which must manage the methods that
it is inheriting with child1 and child2 -- mixins or otherwise.  In this
usage, super() should be called "delegate" as whatever I don't accomplish
in my specialized Parent class, I will get the child classes to do.  Python
automagically delegates any methods that I don't define in Parent to
methods found in child1 and child2.

It seems the issues that everyone encounters with multiple inheritance,
mixins, and such has more to do with terminology (and proper
implementation) than in actuality.

zipher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150616/fd8c7017/attachment.html>


More information about the Python-list mailing list