]> granicus.if.org Git - python/commitdiff
UserDict.get(): New method to mirror built-in dictionaries' get()
authorBarry Warsaw <barry@python.org>
Mon, 6 Oct 1997 17:50:04 +0000 (17:50 +0000)
committerBarry Warsaw <barry@python.org>
Mon, 6 Oct 1997 17:50:04 +0000 (17:50 +0000)
method.

Lib/UserDict.py

index 2f4f541942c158dd6e56ce03c1689c4a140af50e..3b9b157938f9b1b1a6534a7a90790acc95815a42 100644 (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