Shelve provides a persistent store. It relies on pickle, so comes with pickle's caveats about untrusted data. ## Example `put.py` ```python from datetime import datetime import shelve import sys args = sys.argv[1:] if len(args) == 0: keys = ["_"] else: keys = args data = sys.stdin.read() with shelve.open("span") as db: for key in keys: db[key] = data print(f"Stored {len(data)} bytes to {key}") ``` `get.py` ```python from datetime import datetime import shelve import sys args = sys.argv[1:] if len(args) == 0: keys = ["_"] else: keys = args with shelve.open("span") as db: for key in keys: if key in db: print(f"{key}: {db[key]}") else: print(f"{key} ") ``` If [gdbm](/aw/os/gnu/GDBM) is available, Python uses that, else it uses a simple file produced by concatenating pickled data and maintaining a directory which maps key to a byte range.