summaryrefslogtreecommitdiffstats
path: root/Lib/UserDict.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/UserDict.py')
-rw-r--r--Lib/UserDict.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/Lib/UserDict.py b/Lib/UserDict.py
index b560a11..1190221 100644
--- a/Lib/UserDict.py
+++ b/Lib/UserDict.py
@@ -8,11 +8,16 @@ class UserDict:
if len(kwargs):
self.update(kwargs)
def __repr__(self): return repr(self.data)
- def __cmp__(self, dict):
+ def __eq__(self, dict):
if isinstance(dict, UserDict):
- return cmp(self.data, dict.data)
+ return self.data == dict.data
else:
- return cmp(self.data, dict)
+ return self.data == dict
+ def __ne__(self, dict):
+ if isinstance(dict, UserDict):
+ return self.data != dict.data
+ else:
+ return self.data != dict
def __len__(self): return len(self.data)
def __getitem__(self, key):
if key in self.data:
@@ -162,11 +167,13 @@ class DictMixin:
return default
def __repr__(self):
return repr(dict(self.iteritems()))
- def __cmp__(self, other):
- if other is None:
- return 1
+ def __eq__(self, other):
+ if isinstance(other, DictMixin):
+ other = dict(other.iteritems())
+ return dict(self.iteritems()) == other
+ def __ne__(self, other):
if isinstance(other, DictMixin):
other = dict(other.iteritems())
- return cmp(dict(self.iteritems()), other)
+ return dict(self.iteritems()) != other
def __len__(self):
return len(self.keys())