Python ConfigParser using you own config files in python

Storing settings in config files and then let python read the configfiles and to good stuff .

 

Read the file

#Reading config file
 config = ConfigParser.ConfigParser()
 config.read('setting.cfg')

print all items and values in an section

for name, value in config.items("monitor"):
 print ' %s = %s' % (name, value)

Print all items in configfile

for section_name in parser.sections():
    print 'Section:', section_name
    print '  Options:', parser.options(section_name)
    for name, value in parser.items(section_name):
        print '  %s = %s' % (name, value)

My settings.cfg file looks like this

[monitor] <--- Section
check_load:10
name:value

That easy.