Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2f7df12

Browse files
committed
Patch by Paul Sokolovsky to support the get() method.
1 parent 50765ab commit 2f7df12

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Lib/shelve.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ def __len__(self):
5959

6060
def has_key(self, key):
6161
return self.dict.has_key(key)
62+
63+
def get(self, key, default=None):
64+
if self.dict.has_key(key):
65+
return self[key]
66+
return default
6267

6368
def __getitem__(self, key):
6469
f = StringIO(self.dict[key])

0 commit comments

Comments
 (0)