Barry's patch to implement the new setdefault() method.

This commit is contained in:
Guido van Rossum 2000-08-08 16:12:54 +00:00
parent 2b042ded19
commit 164452cec4
2 changed files with 40 additions and 0 deletions

View file

@ -34,3 +34,7 @@ class UserDict:
self.data[k] = v
def get(self, key, failobj=None):
return self.data.get(key, failobj)
def setdefault(self, key, failobj=None):
if not self.data.has_key(key):
self.data[key] = failobj
return self.data[key]