mirror of
https://github.com/python/cpython.git
synced 2025-08-23 02:04:56 +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
|
@ -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])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue