[issue13905] Built-in Types Comparisons should mention rich comparison methods

New submission from Catalin Iacob <iacobcatalin@gmail.com>: 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. ---------- assignee: docs@python components: Documentation messages: 152254 nosy: catalin.iacob, docs@python priority: normal severity: normal status: open title: Built-in Types Comparisons should mention rich comparison methods type: enhancement versions: Python 2.7 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13905> _______________________________________

Catalin Iacob <iacobcatalin@gmail.com> added the comment: Here's my attempt at a patch. It mostly takes the text from the default branch and adds references to __cmp__. ---------- keywords: +patch Added file: http://bugs.python.org/file24361/issue13905v1.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13905> _______________________________________

Roundup Robot added the comment: 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 ---------- nosy: +python-dev resolution: -> fixed stage: -> committed/rejected status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13905> _______________________________________
participants (2)
-
Catalin Iacob
-
Roundup Robot