Use JSON files as if they are Python modules
The mechanism is called "import hooks":<p><a href="https://docs.python.org/3/reference/import.html#import-hooks" rel="nofollow">https://docs.python.org/3/reference/import.html#import-hooks</a><p><a href="https://www.python.org/dev/peps/pep-0302/" rel="nofollow">https://www.python.org/dev/peps/pep-0302/</a><p>You can see the import hook added here:<p><a href="https://github.com/kragniz/json-sempai/blob/master/jsonsempai/magic.py#L5" rel="nofollow">https://github.com/kragniz/json-sempai/blob/master/jsonsempa...</a><p>Import hooks are a great feature in Python.<p>Take the `import` mechanism in the language and reduce it to its barest theoretical formulation - what does it really do? (Name binding.) Think of all the other features in your application that can be reduced to this. (e.g., configuration management) Use the constraints of the import mechanism to guide the design of this feature, and use import hooks to implement it. You'll end up with an implementation that is very "close" to the core language. I would assert that this closeness strongly suggests correctness and composability.<p>Less philosophically, think of the Python virtual machine as a system with lots of "safety valves" and "escape hatches." Import hooks are one such safety valve. Think about all the things you could do easily by hooking into module importing? (Real use-cases: loading code from bitemporal object databases, deprecation of modules, relocation of modules, configuration management, &c.)<p>Of course, there are languages that are much more flexible than Python in this respect. Python aims for a practical flexibility, and I find that, in practice, Python strikes a nice balance.