10000 #1228: new comparison behavior. · python/cpython@9f2c39a · GitHub
[go: up one dir, main page]

Skip to content

Commit 9f2c39a

Browse files
committed
#1228: new comparison behavior.
1 parent 9f27df5 commit 9f2c39a

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

Doc/tutorial/datastructures.rst

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -560,15 +560,8 @@ sequences of the same type::
560560
(1, 2, 3) == (1.0, 2.0, 3.0)
561561
(1, 2, ('aa', 'ab')) < (1, 2, ('abc', 'a'), 4)
562562

563-
Note that comparing objects of different types is legal. The outcome is
564-
deterministic but arbitrary: the types are ordered by their name. Thus, a list
565-
is always smaller than a string, a string is always smaller than a tuple, etc.
566-
[#]_ Mixed numeric types are compared according to their numeric value, so 0
567-
equals 0.0, etc.
568-
569-
570-
.. rubric:: Footnotes
571-
572-
.. [#] The rules for comparing objects of different types should not be relied upon;
573-
they may change in a future version of the language.
574-
563+
Note that comparing objects of different types with ``<`` or ``>`` is legal
564+
provided that the objects have appropriate comparison methods. For example,
565+
mixed numeric types are compared according to their numeric value, so 0 equals
566+
0.0, etc. Otherwise, rather than providing an arbitrary ordering, the
567+
interpreter will raise a :exc:`TypeError` exception.

0 commit comments

Comments
 (0)
0