__lt__ instead of __cmp__

后端 未结 5 2005
暖寄归人
暖寄归人 2020-11-28 02:05

Python 2.x has two ways to overload comparison operators, __cmp__ or the \"rich comparison operators\" such as __lt__. The rich comparison overloads are said to be

5条回答
  •  醉梦人生
    2020-11-28 02:18

    This is covered by PEP 207 - Rich Comparisons

    Also, __cmp__ goes away in python 3.0. ( Note that it is not present on http://docs.python.org/3.0/reference/datamodel.html but it IS on http://docs.python.org/2.7/reference/datamodel.html )

提交回复
热议问题