[Python-Dev] Equality testing (original) (raw)
Ethan Furman ethan at stoneleaf.us
Wed May 18 20:51:54 CEST 2011
- Previous message: [Python-Dev] [Python-checkins] cpython: Skip some tests in the absence of multiprocessing.
- Next message: [Python-Dev] Equality testing
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In Python 3 inequality comparisons became forbidden.
--> 123 < [1, 2, 3] Traceback (most recent call last): File "", line 1, in TypeError: unorderable types: int() < list()
However, equality comparisons are still allowed
--> 123 == [1, 2, 3] False
But you can't mix them (inequality wins)
--> 123 <= [1, 2, 3] Traceback (most recent call last): File "", line 1, in TypeError: unorderable types: int() <= list()
I realize this is probably a Py4000 change if it happens at all, but does this make sense? Shouldn't an attempt to compare to unlike objects be a TypeError, just like trying to order them is?
It bit me when I tried to compare a byte string element with a single character byte string (of course they should have matched, but since the element was an int, the match was not longer True).
Ethan
- Previous message: [Python-Dev] [Python-checkins] cpython: Skip some tests in the absence of multiprocessing.
- Next message: [Python-Dev] Equality testing
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]