Kaydet (Commit) 2f7df12f authored tarafından Guido van Rossum's avatar Guido van Rossum

Patch by Paul Sokolovsky to support the get() method.

üst 50765abb
...@@ -60,6 +60,11 @@ class Shelf: ...@@ -60,6 +60,11 @@ class Shelf:
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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment