PEP 245

Curt Hagenlocher curt at hagenlocher.org
Thu Apr 5 13:44:27 EDT 2001


> Some mechanism is needed to identify an object as
> an implementer of a particular protocol, searching
> for the existance of "getitem" and the like seems
> like very poor practice.  

But you can have this functionality without changing the
syntax of the language or adding new keywords.  Do it the
same way that C++ does, by defining the interface as a
class.  Other than an extremely light frosting of syntactic
sugar, the only advantage I see in PEP 245 is that the
interface definition gets to omit one line of code per
method declaration: raise InterfaceError, "your message here".

Java is the canonical example of a widely-used programming
language that distinguishes between classes and interfaces.
In the case of Java, this distinction is necessary, because
multiple inheritance of classes is not allowed.  This issue
does not exist in Python.

--
Curt Hagenlocher
curt at hagenlocher.org




More information about the Python-list mailing list