how to dynamically instantiate an object inheriting from several classes?

Joe Strout joe at strout.net
Mon Nov 24 13:36:46 EST 2008


On Nov 24, 2008, at 11:10 AM, Matimus wrote:

> I wrote this a while ago. I sort of regret it though. Mixins could
> (and I will argue should) be avoided most of the time by delegating to
> other objects with less functionality. Utilizing many mixin classes
> tends to just make gigantic classes. This is a huge violation of the
> "Single Responsibility Principle".

I see your point, but in this case, I'm building a layout/config tool  
for use with wxPython, and wx uses a fair number of mixins (especially  
for the list control).

> That isn't to say that I don't
> think there is a place for multiple inheritance. Multiple inheritance
> to the point where it is easier to write a metaclass to automatically
> generate your __init__ method than it is to write it yourself is a
> good indicator that you have gone too far. Which is what I did.

I appreciate the sample code, and the thoughtful comments.  You do  
yourself credit.

Best,
- Joe




More information about the Python-list mailing list