Just pass all the configparser
file configparser
. It is in the docs :
Trying to read and parse a list of file names by returning a list of file names that were successfully parsed. If the file names are a string or the Unicode string is treated as a single file name. If the file named in the file names cannot be opened, this file will be ignored. It is designed so that you can specify a list of potential file location configurations (for example, the current directory, home user directory and some system-wide directory) and all existing configuration files in the list will be read. If none of the named files exist, the ConfigParser instance will contain an empty data set. An application that requires loading the initial values ββfrom a file must load the required file or files using readfp () before calling read () for any additional files:
import ConfigParser, os config = ConfigParser.ConfigParser() config.readfp(open('defaults.cfg')) config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')])
Changed in version 2.4: returns a list of successfully parsed file names.
source share