]> granicus.if.org Git - python/commitdiff
Clarify the lack of relationship between rich comparison operators.
authorRaymond Hettinger <python@rcn.com>
Wed, 16 Jul 2003 19:40:23 +0000 (19:40 +0000)
committerRaymond Hettinger <python@rcn.com>
Wed, 16 Jul 2003 19:40:23 +0000 (19:40 +0000)
Prompted by a discussion on comp.lang.python.

Doc/ref/ref3.tex

index 785a995aea2a52232fdf6701c981bc10bc6e0ddb..68d87b438a4f93ed8705cbe9da07aebef0b459a6 100644 (file)
@@ -1089,6 +1089,11 @@ used in a Boolean context, the return value should be interpretable as
 a Boolean value, else a \exception{TypeError} will be raised.
 By convention, \code{False} is used for false and \code{True} for true.
 
+There are no implied relationships among the comparison operators.
+The truth of {\var{x}==\var{y}} does not imply that \code{\var{x}!=\var{y}}
+is false.  Accordingly, when defining \method{__eq__}, one should also
+define \method{__ne__} so that the operators will behave as expected.
+
 There are no reflected (swapped-argument) versions of these methods
 (to be used when the left argument does not support the operation but
 the right argument does); rather, \method{__lt__()} and