UserDict.get(): New method to mirror built-in dictionaries' get()

method.
This commit is contained in:
Barry Warsaw 1997-10-06 17:50:04 +00:00
parent c38c5da5d0
commit fc3e61cd28
1 changed files with 5 additions and 0 deletions

View File

@ -26,3 +26,8 @@ class UserDict:
else:
for k, v in other.items():
self.data[k] = v
def get(self, key, failobj=None):
if self.data.has_key(key):
return self.data[key]
else:
return failobj