> Currently in Python for a third party to add a mixin, they would
> have to hack the class's __bases__, which I am not suggesting here at all.
I'm not suggesting it either. Here's what I meant:
Consider the type "sequential_ordering", which has methods
len() => INTEGER
iter() => ITERABLE
Now let's say that you've got a type of your own, called "mytype", which defines
nitems() => INTEGER
iter() => ITERABLE
Using mixins, you'd do something like:
class adapted_mytype (sequential_ordering, mytype):
def len(self):
return self.nitems()
You can now use "adapted_mytype", which respects both the
"sequential_ordering" protocol and the "mytype" protocol. And a user
can use isinstance to test for that, avoiding "duck typing".
Bill
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com