MCPcopy Create free account
hub / github.com/KentBeck/BPlusTree3 / pop

Method pop

python/bplustree/__init__.py:51–64  ·  view source on GitHub ↗

Remove and return value for key with optional default.

(self, key, *args)

Source from the content-addressed store, hash-verified

49 break
50
51 def pop(self, key, *args):
52 """Remove and return value for key with optional default."""
53 if len(args) > 1:
54 raise TypeError(
55 f"pop expected at most 2 arguments, got {len(args) + 1}"
56 )
57 try:
58 value = self[key]
59 del self[key]
60 return value
61 except KeyError:
62 if args:
63 return args[0]
64 raise
65
66 def popitem(self):
67 """Remove and return an arbitrary (key, value) pair."""

Calls

no outgoing calls