[Tutor] 'Right' way to implement mixins in Python?
Kent Johnson
kent37 at tds.net
Thu May 29 02:11:46 CEST 2008
On Wed, May 28, 2008 at 6:30 PM, Alan Gauld <alan.gauld at btinternet.com> wrote:
> Mixins should be as independant
> as possible from any other classes. Unfortunately thats not
> always possible so you should try to create an abstract
> superclass/interface and use that in your mixins. You can then
> subclass the mixin and replace the abstract class with the local
> concrete manifestation. It means one extra level of inheritance because
> you wind up with an abstract mixin plus the localised mixin.
I don't understand what you mean by this. Python doesn't really have
abstract classes and interfaces. And how is this different than
requiring the mixins to be used with only subclasses of a certain
concrete class?
> Instead build a protocol in the class framework outside the mixins
> and let them coerce the dependencies to suit the mixin interfaces.
Can you explain? I don't know what this means.
Thanks,
Kent
More information about the Tutor
mailing list