Yet Another PEP: Interface Adapter Mechanism __adapt__

Alex Martelli aleaxit at yahoo.com
Wed Mar 21 10:42:13 EST 2001


"Robin Thomas" <robin.thomas at starmedia.net> wrote in message
news:mailman.985177412.11344.python-list at python.org...
    [snip]
> could assimilate issubclass(). I support that work, but I see that it
gives
> some complexity to the meaning of the return value -- in adapter-like
> cases, you want to return self or an adapter of self; in test-like cases,
> you want to return a boolean. I also think that is very cool.

Yes, but, None/non-None generally works fine in a Boolean context
(just test with 'is None'/'is not None' if need be).  Not that I
think boolean use will be frequent, see later.


> A word that works nicely as an operator name, especially a simple word
that
> novices can grasp quickly, would be ideal as a name for this new feature.
>
> Suggestions:
>
> 1) "like"

I suggest 'as' instead -- if the same will-become-an-operator
considerations apply ("give me X ``as'' an Y" sounds more
natural to me than ``like'' does in this context); 'like'
would strongly suggest the boolean reading, which is less
often appropriate (all that boolean testing does is tell
you that, yes, you COULD use X as an Y if you redid the
same operation you just did but avoided throwing away the
result...?!-).


Alex






More information about the Python-list mailing list