Skip to content

Commit

Permalink
Comparisons: some rewording
Browse files Browse the repository at this point in the history
  • Loading branch information
encukou committed Oct 24, 2016
1 parent 0bc72a8 commit 981e176
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions source/comparisons.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ Details and porting strategies follow.
Unorderable Types
~~~~~~~~~~~~~~~~~

Strict approach to comparing in Python 3 makes it impossible to compare the
different types of objects.
The strict approach to comparing in Python 3 makes it generally impossible to
compare different types of objects.

While this example where we try to compare ``int`` and ``str`` in Python 2
For example, in Python 2, comparing ``int`` and ``str``
works (with unpredictable result)::

>>> 2 < '2'
True

In Python 3, it fails with a well described error message::
but in Python 3, it fails with a well described error message::

>>> 2 < '2'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unorderable types: int() < str()

If you still need to compare different types of objects, you have to
implement it by yourself (described below) or use function like ``int()``,
``float()`` or ``str()`` to change type of compared object.
implement a key function to fully describe how disparate types should be
ordered.


Rich Comparisons
Expand Down

0 comments on commit 981e176

Please sign in to comment.