diff options
author | Georg Brandl <georg@python.org> | 2007-10-08 14:08:36 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-10-08 14:08:36 (GMT) |
commit | 9f2c39a7751b648b982373cb097371d69762beff (patch) | |
tree | 9c463315441bf9a8c484a4f37f8b7f1dfc01109a /Doc/tutorial | |
parent | 9f27df56f84fb287a1971093bcf416fb2eca94c6 (diff) | |
download | cpython-9f2c39a7751b648b982373cb097371d69762beff.zip cpython-9f2c39a7751b648b982373cb097371d69762beff.tar.gz cpython-9f2c39a7751b648b982373cb097371d69762beff.tar.bz2 |
#1228: new comparison behavior.
Diffstat (limited to 'Doc/tutorial')
-rw-r--r-- | Doc/tutorial/datastructures.rst | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst index 55b3a3a..54d1922 100644 --- a/Doc/tutorial/datastructures.rst +++ b/Doc/tutorial/datastructures.rst @@ -560,15 +560,8 @@ sequences of the same type:: (1, 2, 3) == (1.0, 2.0, 3.0) (1, 2, ('aa', 'ab')) < (1, 2, ('abc', 'a'), 4) -Note that comparing objects of different types is legal. The outcome is -deterministic but arbitrary: the types are ordered by their name. Thus, a list -is always smaller than a string, a string is always smaller than a tuple, etc. -[#]_ Mixed numeric types are compared according to their numeric value, so 0 -equals 0.0, etc. - - -.. rubric:: Footnotes - -.. [#] The rules for comparing objects of different types should not be relied upon; - they may change in a future version of the language. - +Note that comparing objects of different types with ``<`` or ``>`` is legal +provided that the objects have appropriate comparison methods. For example, +mixed numeric types are compared according to their numeric value, so 0 equals +0.0, etc. Otherwise, rather than providing an arbitrary ordering, the +interpreter will raise a :exc:`TypeError` exception. |