13.2 Using TOML for configuration files
Python offers a variety of ways to package application inputs and configuration files. We’ll look at writing files in TOML notation because this format is elegant and simple. For more information on this format, see https://toml.io/en/.
Most TOML files look quite a bit like INI-format files. This overlap is intentional. When parsed in Python, a TOML file will be a nested dictionary structure.
We might have a file like this:
[some_app]
option_1 = "useful value"
option_2 = 42
[some_app.feature]
option_1 = 7331
This will become a dictionary like the following:
{’some_app’: {’feature’: {’option_1’: 7331},
’option_1’: ’useful...