multiple inheritance of a dynamic list of classes?

Peter Otten __peter__ at web.de
Tue Feb 13 03:14:14 EST 2007


devicerandom at gmail.com wrote:

> Thanks both for suggestions. I still think that using inheritance is
> somehow cleanest in this case (I always hear the mantra "avoid
> multiple inheritance!", but this is one of the cases it seems to make
> a lot of sense to me), but it's nice food for thought/code anyway.

"Avoid inheritance" would be almost as justified :-)

Problems that may arise with this case of multiple inheritance:

- If you need initializers, ensure that they are all invoked
- What would you do about name clashes? To avoid them your plugins need to
know about each other.
- State (instance attributes) is shared among all your plugins. Since you
call all base classes Commands, Python's double-underscore hack won't work.

Peter




More information about the Python-list mailing list