[Python-Dev] containment checking
v+python at g.nevcal.com
Sat Mar 20 00:50:17 CET 2010
On 3/19/2010 3:02 PM, Antoine Pitrou wrote:
> Glenn Linderman<v+python<at> g.nevcal.com> writes:
>> > Sounds to me like containment checking is wrong; that if it gets an
>> > exception during the comparison that it should assume unequal, rather
>> > than aborting, and continue to the next entry.
> Well as the Zen says:
> Errors should never pass silently.
> Unless explicitly silenced.
> If there's a bug in your __eq__ method, rather than getting wrong containment
> results, you get the proper exception.
If there's a bug in your __eq__ method, it may or may not raise an
exception, which may or may not get you wrong containment results. But
it will probably get you buggy results, somehow or another. That's what
design, code reviews, and testing are for.
If the your __eq__ method uses exceptions (the only available method of
out-of-band signalling for binary operators; not all exceptions are
errors) to declare that it can't perform the comparison and produce a
boolean result, that is a case where producing an exception is not an
error, so your quoted Zen doesn't apply.
More information about the Python-Dev