diff options
author | Georg Brandl <georg@python.org> | 2006-06-14 06:29:07 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-06-14 06:29:07 (GMT) |
commit | 772beaafaefbb283d4a4e7d1414269d37be0599b (patch) | |
tree | 23d996139b286d68c676543511b5eecdf63376f7 /Doc/ref/ref5.tex | |
parent | 866a5d89b29903735379fe778c1a08ef3314ba78 (diff) | |
download | cpython-772beaafaefbb283d4a4e7d1414269d37be0599b.zip cpython-772beaafaefbb283d4a4e7d1414269d37be0599b.tar.gz cpython-772beaafaefbb283d4a4e7d1414269d37be0599b.tar.bz2 |
Bug #1501122: mention __gt__ &co in description of comparison order.
Diffstat (limited to 'Doc/ref/ref5.tex')
-rw-r--r-- | Doc/ref/ref5.tex | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Doc/ref/ref5.tex b/Doc/ref/ref5.tex index 89f9977..909e5bb 100644 --- a/Doc/ref/ref5.tex +++ b/Doc/ref/ref5.tex @@ -907,7 +907,10 @@ The operators \code{<}, \code{>}, \code{==}, \code{>=}, \code{<=}, and the values of two objects. The objects need not have the same type. If both are numbers, they are converted to a common type. Otherwise, objects of different types \emph{always} compare unequal, and are -ordered consistently but arbitrarily. +ordered consistently but arbitrarily. You can control comparison +behavior of objects of non-builtin types by defining a \code{__cmp__} +method or rich comparison methods like \code{__gt__}, described in +section~\ref{specialnames}. (This unusual definition of comparison was used to simplify the definition of operations like sorting and the \keyword{in} and @@ -952,7 +955,8 @@ otherwise defined.\footnote{Earlier versions of Python used a dictionary for emptiness by comparing it to \code{\{\}}.} \item -Most other types compare unequal unless they are the same object; +Most other objects of builtin types compare unequal unless they are +the same object; the choice whether one object is considered smaller or larger than another one is made arbitrarily but consistently within one execution of a program. |