summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-08-11 01:54:05 (GMT)
committerGuido van Rossum <guido@python.org>1999-08-11 01:54:05 (GMT)
commit2f7df12f33e27a3df79c9a9543e96df121469c3e (patch)
tree61687828c550fda07a3b55d102412b96e326921d /Lib
parent50765abb29cb3a124c1696a8f29c69db267eb624 (diff)
downloadcpython-2f7df12f33e27a3df79c9a9543e96df121469c3e.zip
cpython-2f7df12f33e27a3df79c9a9543e96df121469c3e.tar.gz
cpython-2f7df12f33e27a3df79c9a9543e96df121469c3e.tar.bz2
Patch by Paul Sokolovsky to support the get() method.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/shelve.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/shelve.py b/Lib/shelve.py
index e617e89..807a0bb 100644
--- a/Lib/shelve.py
+++ b/Lib/shelve.py
@@ -59,6 +59,11 @@ class Shelf:
def has_key(self, key):
return self.dict.has_key(key)
+
+ def get(self, key, default=None):
+ if self.dict.has_key(key):
+ return self[key]
+ return default
def __getitem__(self, key):
f = StringIO(self.dict[key])