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

Method pop

Lib/collections/__init__.py:247–267  ·  view source on GitHub ↗

od.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised.

(self, key, default=__marker)

Source from the content-addressed store, hash-verified

245 __marker = object()
246
247 def pop(self, key, default=__marker):
248 '''od.pop(k[,d]) -> v, remove specified key and return the corresponding
249 value. If key is not found, d is returned if given, otherwise KeyError
250 is raised.
251
252 '''
253 marker = self.__marker
254 result = dict.pop(self, key, marker)
255 if result is not marker:
256 # The same as in __delitem__().
257 link = self.__map.pop(key)
258 link_prev = link.prev
259 link_next = link.next
260 link_prev.next = link_next
261 link_next.prev = link_prev
262 link.prev = None
263 link.next = None
264 return result
265 if default is marker:
266 raise KeyError(key)
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.

Callers 2

_signature_get_partialFunction · 0.95
test_popMethod · 0.95

Calls 1

popMethod · 0.45

Tested by 1

test_popMethod · 0.76