Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Friday, July 01, 2011

using ConfigParser in python

You need to use absolute paths when pointing to your config file
import ConfigParser
import os
config = ConfigParser.ConfigParser()
config.read(os.getcwd() + '/utils/settings.cfg')
This made me scratch my head for a while!  Gives you errors when you assume it to use relative paths.
File "/usr/lib64/python2.4/ConfigParser.py", line 511, in get
    raise NoSectionError(section)
ConfigParser.NoSectionError: No section: 'config'