summaryrefslogtreecommitdiffstats
path: root/Lib/UserDict.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1997-10-06 17:50:04 (GMT)
committerBarry Warsaw <barry@python.org>1997-10-06 17:50:04 (GMT)
commitfc3e61cd2816274e49dfd42ddc29b38d3118bd21 (patch)
treec390fd7fdaadf784df4a5e2f2455d2e63d236818 /Lib/UserDict.py
parentc38c5da5d0ce35442e859d64e6cfa734688a470e (diff)
downloadcpython-fc3e61cd2816274e49dfd42ddc29b38d3118bd21.zip
cpython-fc3e61cd2816274e49dfd42ddc29b38d3118bd21.tar.gz
cpython-fc3e61cd2816274e49dfd42ddc29b38d3118bd21.tar.bz2
UserDict.get(): New method to mirror built-in dictionaries' get()
method.
Diffstat (limited to 'Lib/UserDict.py')
-rw-r--r--Lib/UserDict.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/UserDict.py b/Lib/UserDict.py
index 2f4f541..3b9b157 100644
--- a/Lib/UserDict.py
+++ b/Lib/UserDict.py
@@ -26,3 +26,8 @@ class UserDict:
else:
for k, v in other.items():
self.data[k] = v
+ def get(self, key, failobj=None):
+ if self.data.has_key(key):
+ return self.data[key]
+ else:
+ return failobj