[Python-Dev] Overloading comparison operator for lists (original) (raw)
Terry Reedy tjreedy at udel.edu
Wed May 29 01:43:07 EDT 2019
- Previous message (by thread): [Python-Dev] Overloading comparison operator for lists
- Next message (by thread): [Python-Dev] Overloading comparison operator for lists
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message (by thread): [Python-Dev] Overloading comparison operator for lists
- Next message (by thread): [Python-Dev] Overloading comparison operator for lists
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]