Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc3e61c

Browse files
committed
UserDict.get(): New method to mirror built-in dictionaries' get()
method.
1 parent c38c5da commit fc3e61c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Lib/UserDict.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,8 @@ def update(self, other):
2626
else:
2727
for k, v in other.items():
2828
self.data[k] = v
29+
def get(self, key, failobj=None):
30+
if self.data.has_key(key):
31+
return self.data[key]
32+
else:
33+
return failobj

0 commit comments

Comments
 (0)