update_setting(path, key, value) that reads a JSON file into a dict (treating a missing file as {}), sets key = value, and writes it back pretty-printed. The read-modify-write cycle every app's settings module performs.update_setting('cfg.json', 'theme', 'dark')cfg.json now contains {"theme": "dark"} plus prior keysExisting settings survive; one key changed.
try/except FileNotFoundError around the read.
json.load / json.dump with file objects.