[Tutor] 'Right' way to implement mixins in Python?
Kent Johnson
kent37 at tds.net
Thu May 29 23:29:45 CEST 2008
On Thu, May 29, 2008 at 4:57 PM, chombee <chombee at nerdshack.com> wrote:
> Yeah I'd like to see how this dependency on an abstract interface is
> implemented in Python also.
Python doesn't really have a concept of abstract interface, it uses
duck typing instead.
> I suppose I could get the __init__ methods of the mixins to look for the
> base class and complain if it's not there.
I think you could just put
assert isinstance(self, RequiredBaseClass), "Missing required base class"
in the mixin's __init__() method.
Kent
More information about the Tutor
mailing list