[Python-ideas] __iter__ implies __contains__?
Masklinn
masklinn at masklinn.net
Sat Oct 1 21:40:37 CEST 2011
On 2011-10-01, at 20:33 , Antoine Pitrou wrote:
> Ah, thanks for the pointer.
> I think we should add a custom IOBase.__contains__ raising a TypeError,
> then. The current semantics don't match what most people would expect
> from a "file containment" predicate.
I think it'd also be nice to add them to some "chopping block" list for
Python 4: I've yet to see these fallbacks result in anything but pain
and suffering, and they can be genuinely destructive and cause hard-to-
track bug, especially with modern Python code's tendency to use
(non-restartable) iterators and generators (send a generator to a
function which seems to take them, it performs some sort of
containment check before processing, the containment consumes the
generator and proceeds to not do any processing…)
More information about the Python-ideas
mailing list