MCPcopy Index your code
hub / github.com/RustPython/RustPython / setdefault

Method setdefault

Lib/collections/__init__.py:269–277  ·  view source on GitHub ↗

Insert key with a value of default if key is not in the dictionary. Return the value for key if key is in the dictionary, else default.

(self, key, default=None)

Source from the content-addressed store, hash-verified

267 return default
268
269 def setdefault(self, key, default=None):
270 '''Insert key with a value of default if key is not in the dictionary.
271
272 Return the value for key if key is in the dictionary, else default.
273 '''
274 if key in self:
275 return self[key]
276 self[key] = default
277 return default
278
279 @_recursive_repr()
280 def __repr__(self):

Callers 1

test_setdefaultMethod · 0.95

Calls

no outgoing calls

Tested by 1

test_setdefaultMethod · 0.76