[Python-ideas] Non-boolean return from __contains__

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Jul 28 03:03:48 CEST 2010


Guido van Rossum wrote:
> On Tue, Jul 27, 2010 at 3:29 PM, Mathias Panzenböck
 >
>>So it doesn't help that 'in' may return something else than a bool
>>because the method is called on the wrong object for your purposes.
> 
>
> Well that pretty much kills the proposal. I can't believe nobody
> (including myself) figured this out earlier in the thread. :-(

Alternatively, it could be taken as a sign that there is
a special method missing -- there should be an __in__
method that is tried on the first operand before trying
__contains__ on the second. (And if we'd thought of this
at the beginning, __contains__ would have been called
__rin__. :-)

-- 
Greg




More information about the Python-ideas mailing list