[Python-ideas] __contains__=None (was: __iter__ implies __contains__?)

Jan Kaliszewski zuo at chopin.edu.pl
Tue Oct 4 02:09:29 CEST 2011


Nick Coghlan dixit (2011-10-03, 18:00):

[...]
> duck-typed check for __contains__ would break for classes that
> explicitly raise TypeError, as is proposed for _BaseIO).

Maybe there should be possible to explicitly disallow the 'in' test by
setting __contains__ to None (similar to already settled __hash__=None
for non-hashables).

Cheers.
*j




More information about the Python-ideas mailing list