[Python-ideas] Non-boolean return from __contains__

Raymond Hettinger raymond.hettinger at gmail.com
Wed Jul 28 03:09:17 CEST 2010


On Jul 27, 2010, at 6:03 PM, Greg Ewing wrote:

> 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__. :-)

Don't forget __not_in__ and __not_rin__ ;-)


Raymond


More information about the Python-ideas mailing list