[Python-Dev] Equality testing (original) (raw)
Benjamin Peterson benjamin at python.org
Wed May 18 21:22:18 CEST 2011
- Previous message: [Python-Dev] Equality testing
- Next message: [Python-Dev] Equality testing
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2011/5/18 Ethan Furman <ethan at stoneleaf.us>:
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?
No. Ordering for types which completely different doesn't make any sense, but equality testing is just fine because it has an obvious answer: no.
-- Regards, Benjamin
- Previous message: [Python-Dev] Equality testing
- Next message: [Python-Dev] Equality testing
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]