mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #1717: Remove cmp. Stage 1: remove all uses of cmp and __cmp__ from
the standard library and tests.
This commit is contained in:
parent
191e850053
commit
a56c467ac3
32 changed files with 210 additions and 216 deletions
|
@ -520,11 +520,29 @@ class NamedNodeMap(object):
|
|||
|
||||
__len__ = _get_length
|
||||
|
||||
def __cmp__(self, other):
|
||||
def _cmp(self, other):
|
||||
if self._attrs is getattr(other, "_attrs", None):
|
||||
return 0
|
||||
else:
|
||||
return cmp(id(self), id(other))
|
||||
return (id(self) > id(other)) - (id(self) < id(other))
|
||||
|
||||
def __eq__(self, other):
|
||||
return self._cmp(other) == 0
|
||||
|
||||
def __ge__(self, other):
|
||||
return self._cmp(other) >= 0
|
||||
|
||||
def __gt__(self, other):
|
||||
return self._cmp(other) > 0
|
||||
|
||||
def __le__(self, other):
|
||||
return self._cmp(other) <= 0
|
||||
|
||||
def __lt__(self, other):
|
||||
return self._cmp(other) < 0
|
||||
|
||||
def __ne__(self, other):
|
||||
return self._cmp(other) != 0
|
||||
|
||||
def __getitem__(self, attname_or_tuple):
|
||||
if isinstance(attname_or_tuple, tuple):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue