[Python-Dev] Overloading comparison operator for lists
tjreedy at udel.edu
Wed May 29 01:43:07 EDT 2019
On 5/28/2019 11:35 PM, Montana Burr wrote:
> What is the justification for causing list == 3 to evaluate to False,
> besides the obvious "a list cannot equal a number"?
That is completely sufficient. The default comparison is by id, and a
class must override to get something different. The 'default' override
is compare by class and if equal, compare by value. Numbers are odd in
allowing instances of different classes compare equal.
Terry Jan Reedy
More information about the Python-Dev