diff options
author | Georg Brandl <georg@python.org> | 2008-09-09 19:31:57 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2008-09-09 19:31:57 (GMT) |
commit | 9609cea0449979a56049bbfe7251e98621acfb2b (patch) | |
tree | cb2d4d37540f256378fce68ed4f969cd2e139aea /Doc/reference/expressions.rst | |
parent | 7cd67cc992acb659f1673706e037ee835648d60b (diff) | |
download | cpython-9609cea0449979a56049bbfe7251e98621acfb2b.zip cpython-9609cea0449979a56049bbfe7251e98621acfb2b.tar.gz cpython-9609cea0449979a56049bbfe7251e98621acfb2b.tar.bz2 |
#3803: fix docs for comparison of unequal types.
Diffstat (limited to 'Doc/reference/expressions.rst')
-rw-r--r-- | Doc/reference/expressions.rst | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index 945df61..7931b95 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -1003,16 +1003,13 @@ pretty). The operators ``<``, ``>``, ``==``, ``>=``, ``<=``, and ``!=`` compare 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 *always* compare unequal, and are ordered consistently but arbitrarily. -You can control comparison behavior of objects of non-builtin types by defining -a :meth:`__cmp__` method or rich comparison methods like :meth:`__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 :keyword:`not in` operators. -In the future, the comparison rules for objects of different types are likely to -change.) +numbers, they are converted to a common type. Otherwise, the ``==`` and ``!=`` +operators *always* consider objects of different types to be unequal, while the +``<``, ``>``, ``>=`` and ``<=`` operators raise a :exc:`TypeError` when +comparing objects of different types that do not implement these operators for +the given pair of types. You can control comparison behavior of objects of +non-builtin types by defining rich comparison methods like :meth:`__gt__`, +described in section :ref:`customization`. Comparison of objects of the same type depends on the type: |