26 Jul
2019
26 Jul
'19
12:15 p.m.
Steven D'Aprano wrote:
Equality tests really ought not to fail. If they do fail, it should be considered a bug in the __eq__ method, not an intentional result.
To allow == tests to fail is just a way of sneaking in a three-value logic into the language, only using an extremely inconvenient API:
In the case being considered here, I would argue that attempting to compare dict.values() results is a symptom of a bug in the code performing that comparison, or at least a smell suggesting that the programmer hasn't thought something through properly. The remedy is to re-write that code to be explicit about what is really wanted. There is no three-valued logic involved here. -- Greg