This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Built-in Types Comparisons should mention rich comparison methods
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: catalin.iacob, docs@python, python-dev
Priority: normal Keywords: patch

Created on 2012-01-29 19:58 by catalin.iacob, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue13905v1.patch catalin.iacob, 2012-01-29 20:01 review
Messages (3)
msg152254 - (view) Author: Catalin Iacob (catalin.iacob) * Date: 2012-01-29 19:58
In 2.7 the Comparisons section of stdtypes.rst only talks about __cmp__ and never mentions the rich comparison methods:
"Instances of a class normally compare as non-equal unless the class defines the __cmp__() method. Refer to Basic customization) for information on the use of this method to effect object comparisons."

The first sentence is false, instances can also compare as equal if they define __eq__. And since __cmp__ is gone in Python3, I think the rich comparison methods should at least be mentioned, or even emphasized over __cmp__ to help people write more forward compatible code.
msg152255 - (view) Author: Catalin Iacob (catalin.iacob) * Date: 2012-01-29 20:01
Here's my attempt at a patch. It mostly takes the text from the default branch and adds references to __cmp__.
msg199596 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-12 16:43
New changeset 9f1e1da820fb by Georg Brandl in branch '2.7':
Closes #13905: mention rich-comparison methods in addition to __cmp__ when documenting how to make classes comparable and orderable.
http://hg.python.org/cpython/rev/9f1e1da820fb
History
Date User Action Args
2022-04-11 14:57:26adminsetgithub: 58113
2013-10-12 16:43:48python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg199596

resolution: fixed
stage: resolved
2012-01-29 20:01:56catalin.iacobsetfiles: + issue13905v1.patch
keywords: + patch
messages: + msg152255
2012-01-29 19:58:51catalin.iacobcreate