mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Barry's patch to implement the new setdefault() method.
This commit is contained in:
parent
2b042ded19
commit
164452cec4
2 changed files with 40 additions and 0 deletions
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue