Yet Another PEP: Query Protocol Interface or __query__
neelk at alum.mit.edu
Wed Mar 21 04:15:11 CET 2001
On 20 Mar 2001 17:47:35 -0800, Aahz Maruch <aahz at panix.com> wrote:
>[posted & e-mailed]
>In article <Pine.LNX.4.21.0103201837570.21343-100000 at clarkevans.com>,
>Clark C. Evans <cce at clarkevans.com> wrote:
>> A new built-in method, __query__ is proposed. This method has
>> a single argument, an interface protocol identifier, and either
>> returns an object supporting the given protocol, or throws an
>> unknown exception. [...]
> Most importantly, how does one find out what interfaces an object *does*
Why is this important?
If you are writing some client code, presumably all you care about is
that the object you receive supports certain interfaces X, Y and Z
that you are using. It wouldn't seem to matter at all what -other-
interfaces it supports.
I can see heavy-duty reflective programs wanting this capability, but
it doesn't seem like something that would be used very often in
regular code. So perhaps it is better left out of the first draft.
More information about the Python-list