From 2f7df12f33e27a3df79c9a9543e96df121469c3e Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 11 Aug 1999 01:54:05 +0000 Subject: Patch by Paul Sokolovsky to support the get() method. --- Lib/shelve.py | 5 +++++ 1 file changed, 5 insertions(+) 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]) -- cgit v0.12