On 13 Feb, 09:14, Peter Otten <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] 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 :-)
Why? > Problems that may arise with this case of multiple inheritance: > > - If you need initializers, ensure that they are all invoked Yes, I figured it out. This should be easy in this case. > - What would you do about name clashes? To avoid them your plugins need to > know about each other. Yes, I know, but I can't see any simple solution to this (if you can, please share it with me!). The cmd module works by interpreting any method starting with "do_" as a command, so "do_blah" becomes the "blah" command. If two people write a "do_blah" command, and both plugins are used, I see no easy way to solve the issue (apart rewriting a cmd module). Perhaps there can be some previous sanity check in each modules dict to see if there are obvious namespace clashings, and in this case issue a warning. I don't know. > - State (instance attributes) is shared among all your plugins. Since you > call all base classes Commands, Python's double-underscore hack won't work. What double-underscore hack are you referring to? (sigh, my python limits are all arising...) I can call all base classes PluginNameCommand, however, this wouldn't break the thing (I'm still at the very early planning stage) and would maybe work. m. -- http://mail.python.org/mailman/listinfo/python-list