The ConfigParser class is designed for this task, see http://docs.python.org/lib/module-ConfigParser.html