the following code illustrates how you read configuration file and supply default values to some of the variablesfrom configparser import configparser use from configparser in python dictionary of default variable settings defaults 'basedir'/users/beazley/appcreate configparser object and read the ini file cfg configparser(defaultscfg read('appconfig ini'after you have read configuration fileyou use the get(method to retrieve option values for examplecfg get('output','logfile''/users/beazley/app/logs/app logcfg get('input','infile''/users/beazley/app/input/initial datcfg getboolean('output','logging'true hereyou immediately see some interesting features firstconfiguration parameters are case insensitive thusif your program is reading parameter 'logfile'it does not matter if the configuration file uses 'logfile''logfile'or 'logfilesecondconfiguration parameters can include variable substitutions such as '%(basedir)sand '%(logdir)sas seen in the file these substitutions are also case insensitive moreoverthe definition order of configuration parameters does not matter in these substitutions for examplein appconfig inithe logfile parameter makes reference to the logdir parameterwhich is defined later in the file finallyvalues in configuration files are often interpreted correctly even if they don' exactly match python syntax or datatypes for examplethe 'onvalue of the logging parameter is interpreted as true by the cfg getboolean(method configuration files also have the ability to be merged together for examplesuppose the user had their own configuration file with custom settingsuserconfig ini per-user settings [outputlogging=off [inputbasedir=/tmp you can merge the contents of this file in with already loaded configuration parameters for examplecfg read('userconfig ini'['userconfig ini'cfg get('output','logfile''/users/beazley/app/logs/app logcfg get('output','logging''offcfg get('input','infile''/tmp/input/initial datf lib fl ff