Multiple inheritance: Interface problem workaround, please comment this

Axel Straschil axel at straschil.com
Fri Apr 8 02:40:20 EDT 2005


Hello!

>     (1) make A or B a mixin class that doesn't need __init__ called, or

Would be a solution for classes that just give functionality, no
data-structures. In that case, i would use functions, no classes ;-)

I've seen code where there are classes without init and the hope that
self has what they expect, not realy the blackbox oop should produce!

>     (2) make class AB inherit from A and delegate to B (or vice versa)

As every multiple inheritance can be solved as single inheritance, if no
better solution for my "hungry monster problem" is found, this would be
the best way. Don't take my AB example as a real word example ;-)

Also think of to libraries with classes which have inheritance depth
five or more (that's what I've got). Somtimes you want to stick things
together without knowing the inheritance tree.

So, if there are ready class-modules, and I want to use them for
multiple inheritance, I've to rewrite the init's of classes in the
module!

For me, python is the best solution in oop-webprogramming (tried perl,
got ugly code, tried php, got php ;-), tried C++, takes too long for web
projects). The only thing I'm dislike is the super thing with multiple
inheritance, maby I shoud see pythons multiple inheritance as a nice to
have and not to use thing ;-)

Thanks,
AXEL.



More information about the Python-list mailing list