Let Non-technical People Tweak Your Software Without Pain.
A brief guide to using TOML configuration files in Python projects.
How’d you change the behavior of a software project based on a set of parameters?
You could use environment variables. But what if you want complex structures in the parameters?
Can you use JSON? Yes, you can. JSON files don’t allow comments. How’d you describe your parameters to readers?
The answer is to use a TOML configuration file.
Why should we use a config file, and why TOML?
Config files are great ways to extract the project parameters. When you share your code with others, they know exactly where to make changes to tweak the behavior of the software.
For instance, say yours is a website codebase that supports several themes. Others who set up your code can go to the config file and change the theme variable to a different one. It’s more convenient than going to the codebase and editing the theme in various files.
But to let your users know what themes are available, you need to have comments on the config files. You can say your website supports ‘dark’, ‘light,’ ‘pop,’ and ‘grayscale’ themes. JSON files fall short, as…