mirror of https://github.com/python/cpython.git
Patch by Paul Sokolovsky to support the get() method.
This commit is contained in:
parent
50765abb29
commit
2f7df12f33
|
@ -60,6 +60,11 @@ def __len__(self):
|
||||||
def has_key(self, key):
|
def has_key(self, key):
|
||||||
return self.dict.has_key(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):
|
def __getitem__(self, key):
|
||||||
f = StringIO(self.dict[key])
|
f = StringIO(self.dict[key])
|
||||||
return Unpickler(f).load()
|
return Unpickler(f).load()
|
||||||
|
|
Loading…
Reference in New Issue