From fc3e61cd2816274e49dfd42ddc29b38d3118bd21 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Mon, 6 Oct 1997 17:50:04 +0000 Subject: [PATCH] UserDict.get(): New method to mirror built-in dictionaries' get() method. --- Lib/UserDict.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Lib/UserDict.py b/Lib/UserDict.py index 2f4f541942..3b9b157938 100644 --- a/Lib/UserDict.py +++ b/Lib/UserDict.py @@ -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 -- 2.40.0