Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4d6e8fe

Browse files
committed
Clarify the lack of relationship between rich comparison operators.
Prompted by a discussion on comp.lang.python.
1 parent 71adf7e commit 4d6e8fe

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Doc/ref/ref3.tex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,11 @@ \subsection{Basic customization\label{customization}}
10891089
a Boolean value, else a \exception{TypeError} will be raised.
10901090
By convention, \code{False} is used for false and \code{True} for true.
10911091

1092+
There are no implied relationships among the comparison operators.
1093+
The truth of {\var{x}==\var{y}} does not imply that \code{\var{x}!=\var{y}}
1094+
is false. Accordingly, when defining \method{__eq__}, one should also
1095+
define \method{__ne__} so that the operators will behave as expected.
1096+
10921097
There are no reflected (swapped-argument) versions of these methods
10931098
(to be used when the left argument does not support the operation but
10941099
the right argument does); rather, \method{__lt__()} and

0 commit comments

Comments
 (0)