summaryrefslogtreecommitdiffstats
path: root/Lib/UserDict.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>1997-06-03 13:07:59 (GMT)
committerFred Drake <fdrake@acm.org>1997-06-03 13:07:59 (GMT)
commitbd40d7e69ffd53f36a315605fc849bb12ae1f55f (patch)
treead10c4df063bf8b7747aeff2552a62477d4ab7d4 /Lib/UserDict.py
parent36bab7dbafc1efe51e6d20d32be86de0cd0b4b86 (diff)
downloadcpython-bd40d7e69ffd53f36a315605fc849bb12ae1f55f.zip
cpython-bd40d7e69ffd53f36a315605fc849bb12ae1f55f.tar.gz
cpython-bd40d7e69ffd53f36a315605fc849bb12ae1f55f.tar.bz2
Added the new dictionary methods to the wrapper class.
Diffstat (limited to 'Lib/UserDict.py')
-rw-r--r--Lib/UserDict.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/UserDict.py b/Lib/UserDict.py
index f6b2f82..3ee4743 100644
--- a/Lib/UserDict.py
+++ b/Lib/UserDict.py
@@ -12,7 +12,23 @@ class UserDict:
def __getitem__(self, key): return self.data[key]
def __setitem__(self, key, item): self.data[key] = item
def __delitem__(self, key): del self.data[key]
+ def clear(self): return self.data.clear()
+ def copy(self):
+ if self.__class__ is UserDict:
+ new = UserDict()
+ new.dict = self.data.copy()
+ else:
+ new = self.__class__() # XXX assumption: constructor signature
+ for k, v in self.items():
+ new[k] = v
+ return new
def keys(self): return self.data.keys()
def items(self): return self.data.items()
def values(self): return self.data.values()
def has_key(self, key): return self.data.has_key(key)
+ def update(self, other):
+ if type(other) is type(self.data):
+ self.data.update(other)
+ else:
+ for k, v in other.items():
+ self.data[k] = v