Rather than writing general code, I've made a specific interface for the use, to make it emotionally easier and appease the great oppressions. However, I've tried to offset and normalize it a little, to make it easier to collect and generalize if the great oppressions lift. class API: def __init__(self, name, HOME = os.path.expanduser('~/.apifudge')): self.name = name self.path = os.path.join(HOME, self.name) self.examples_path = os.path.join(self.path, 'examples') os.makedirs(self.examples_path, exist_ok=True) def get_examples(self): return { fn: open(os.path.join(self.examples_path, fn)).read() for fn in os.listdir(self.examples_path) } def set_example(self, data, name = None): fn = os.path.join(self.examples_path, name) try: with open(fn + '.new', 'w') as f: f.write(data) os.rename(fn + '.new', fn) except: os.unlink(fn + '.new') raise