Generate and read config files in Python

For big python scripts it is better to gather all input variables from a separate config file. This is an example of how to read values from a config.txt

file:

import configparser
filename = "C:/config.txt"
config = configparser.ConfigParser()
config.read(filename)
print(config.sections())
print(config['Paths']['InDatasetsPath'])

The config.txt contents:

[Paths]
InDatasetsPath=C:/in_datasets/
OutDatasetsPath=C:/out_datasets/
OutFiguresPath=C:/out_figures/
[SectionTwo]
Parameter1=x
Parameter2=y