Guido van Rossum sagte: > On 4/7/06, Walter Dörwald <[EMAIL PROTECTED]> wrote: >> An Interface is an abstract class that you subclass to make it a concrete >> implementation. > > That's not the view of most people who use the word interface these days. Not > in Zope (see Fred Drake's post), not in Java. > >> If you have an adapter that adapts to the >> FooInterface why shouldn't it return a FooInterface object? > > Because implementing an interface and extending a class are separate concepts. > > Did you forget duck typing? Something can be a sequence without > subclassing a common base class.
True, with adaption it's only relevant whether there's a dispatch condition in the registry that is true. The return type of the adaption call is irrelevant. But somehow this changes duck typing: It's no longer relevant which operation you want to perform (by doing EAFP with the method you want to call), but whether someone has registered a adapter with a dispatch condition that matches your object (which itself might use duck typing): @overload def sequence(obj): raise TypeError("can't convert to sequence") @sequence.when("hasattr(obj, '__getitem__') and hasattr(obj, '__len__')") def pythonseqassequence(obj): class Sequence(object): def __init__(self, obj): self.obj = obj def getitem(self, index): return self.obj[index] def len(self): return len(self.obj) return pythonseqassequence(obj) Servus, Walter _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com