Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
150db25d
Commit
150db25d
authored
Sep 09, 2008
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#3803: fix docs for comparison of unequal types.
parent
4af9aea5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
10 deletions
+7
-10
Doc/reference/expressions.rst
Doc/reference/expressions.rst
+7
-10
No files found.
Doc/reference/expressions.rst
View file @
150db25d
...
...
@@ -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:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment