Closed
Description
The return False behavior should only be for ==
(and True for !=
). Related to #988.
>>> object() == object()
False
>>> object() != object()
True
This can be very confusing in some cases, especially for !=
:
>>> ndtest(10) != object()
False
>>> ndtest(10) > object()
False
>>> ndtest(10) < object()
False
>>> ndtest(10) + object()
False
Usually comparison operators return TypeError in that case:
>>> object() > object()
TypeError: '>' not supported between instances of 'object' and 'object'
Other arithmetic operations also return TypeError:
>>> object() + object()
TypeError: unsupported operand type(s) for +: 'object' and 'object'
As far as I am concerned, I would use the same message for both cases.