Issue #1717: Remove cmp. Stage 1: remove all uses of cmp and __cmp__ from

the standard library and tests.
This commit is contained in:
Mark Dickinson 2009-01-27 18:17:45 +00:00
parent 191e850053
commit a56c467ac3
32 changed files with 210 additions and 216 deletions

View file

@ -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):