summaryrefslogtreecommitdiffstats
path: root/Lib/UserDict.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1993-11-30 13:43:54 (GMT)
committerGuido van Rossum <guido@python.org>1993-11-30 13:43:54 (GMT)
commitae3b3a33d85134b51505b3f0f3fdaf6afbffa79b (patch)
treeed5f31c45378ce3be6e096f559fa645ea5f02a42 /Lib/UserDict.py
parent590baa4a7a43b596119b47f605e3e570c2b3b0ee (diff)
downloadcpython-ae3b3a33d85134b51505b3f0f3fdaf6afbffa79b.zip
cpython-ae3b3a33d85134b51505b3f0f3fdaf6afbffa79b.tar.gz
cpython-ae3b3a33d85134b51505b3f0f3fdaf6afbffa79b.tar.bz2
* test_*.py: new lambda syntax (also affects tests for filter, map,
reduce) * ftplib.py: added default callback for retrlines; added dir() method * ftplib.py: don't return self in self.connect(); added hack so that if 'CDUP' is not understood, 'CWD ..' is tried. * ftplib.py: second method called init() should have been called connect(); if __init__ sees more than one argument, it will also try to login().
Diffstat (limited to 'Lib/UserDict.py')
-rw-r--r--Lib/UserDict.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/UserDict.py b/Lib/UserDict.py
new file mode 100644
index 0000000..f6b2f82
--- /dev/null
+++ b/Lib/UserDict.py
@@ -0,0 +1,18 @@
+# A more or less complete user-defined wrapper around dictionary objects
+
+class UserDict:
+ def __init__(self): self.data = {}
+ def __repr__(self): return repr(self.data)
+ def __cmp__(self, dict):
+ if type(dict) == type(self.data):
+ return cmp(self.data, dict)
+ else:
+ return cmp(self.data, dict.data)
+ def __len__(self): return len(self.data)
+ 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 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)