mirror of
https://github.com/python/cpython.git
synced 2025-08-23 18:24:46 +00:00
Patch by Paul Sokolovsky to support the get() method.
This commit is contained in:
parent
50765abb29
commit
2f7df12f33
1 changed files with 5 additions and 0 deletions
|
@ -60,6 +60,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])
|
||||
return Unpickler(f).load()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue