mirror of https://github.com/python/cpython
UserDict.get(): New method to mirror built-in dictionaries' get()
method.
This commit is contained in:
parent
c38c5da5d0
commit
fc3e61cd28
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue