I need to store configurations (key/value) for a Python application and I am searching for the best way to store these configurations in a file.
I run into Python’s ConfigParser and I wondered if the INI file format is really still appropriate nowadays?!
Does there exist a more up-to-date format or is INI still the recommended way to go? (XML, JSON, …)
Please share your opinions/recommendations…
Consider using plain Python files as configuration files.
An example (
config.py):In your program, load the config file using
exec(docs):I like this approach, for the following reasons:
The approach is widely used, a few examples:
execfile, it usesimportto read/executesettings.pyAFAIK, but the end result is the same: the code inside the settings file is executed.~/.bashrcon startup.site.pyon startup.