Yet Another PEP: Query Protocol Interface or __query__

Clark C. Evans cce at clarkevans.com
Wed Mar 21 21:08:40 EST 2001


On Thu, 22 Mar 2001, Delaney, Timothy wrote:
> I think the major trap would be going with a system which did not have
> sufficient expressiveness. One of the problems with passing a base class
> object (or class instance) to __adapt__() is that there is no standard way
> to specify requirements other than "interface has these methods".

The goal of this PEP (if it gets accepted as a PEP...) is to 
provide a simple mechanism for "adapt", _without_ having to 
dive into the many many issues that the type special interest
group is exploring.  If done right, the mechanism can be expanded 
later to handle interfaces or signature specifications, instead
of a class.  I want to keep this simple...

> In interface descriptor class is much more general, and much more easily
> extended. For example, the first iteration could simply be used to add
> method requirements. Then we could add method parameter and return type
> signatures. Then pre- and post- conditions (such as parameter #3 <= 5). And
> so on.

Right.  And this PEP proposal would not preclude this at
all, and infact, this type of stuff could be plugged in
as additional "work" that the adapt method can perform.

> I think the adapt stuff would work as follows...

You should read up on Michel Pelletier's work PEP 245
"Python Interfaces" which is at:

  http://python.sourceforge.net/peps/pep-0245.html

Clark





More information about the Python-list mailing list