Archive
Behaviour of ConfigParser.read() – Python
I am playing around with python for a while. My code uses ConfigParser to parse a piece of configuration file. Now the documentation says ConfigParser.read() accepts list of file names as an argument and tries to read them one by one and returns the list of files that are read successfully.This behaviour is helpful when you have multiple configuration files all across your system.
what the documentation doesn’t tell you is, which configuration file it will use for further processing in case of multiple successful reads. ConfigParser actually uses the last read file for further processing. So prioritize your configuration files accordingly
import ConfigParser
config_parser = ConfigParser.ConfigParser()
filenames = [‘low_priority_file’,’medium_priority_file’,’high_priority_file’]
config_parser.read(filenames)