As the title says, I am looking for a way to manage config files in python with options that should be accessible across multiple source files and multiple processes, with a (hopefully) human readable format, where I can also set some options programmatically.
I have tried/looked at the following:
- Using a
global.py
: file and importing it everywhere. However, when I change any of the values, the change is not reflected in the other processes. I suppose this cannot be done as per this answer: Globals variables and Python multiprocessing. Is there a way to make this work? configparser
: This seems to be a really good option, though I don't understand the following: When I change some of the options after reading a file, how do I make sure this change is reflected in the other files/processes?configargparser
: I like this as well, since it is extremely customizable. However, I again have the same question as above.yaml
: This seems to be the most human readable option. In that, I can give lists and dicts as arguments without much of a problem. I still don't know how to use it across files and processes though. I guess one way would be to read everything in a main file, dump it somewhere before spawning other processes and read that dumped file in other processes. Is there a better way?