Skip to content

Instantly share code, notes, and snippets.

@curzona
Created March 8, 2014 17:46
Show Gist options
  • Save curzona/9435762 to your computer and use it in GitHub Desktop.
Save curzona/9435762 to your computer and use it in GitHub Desktop.
Read config file into a dictionary with ConfigParser
import ConfigParser
def parser_config(filename):
dict = {}
config = ConfigParser.ConfigParser()
config.optionxform = str
config.read(filename)
for section in config.sections():
dict[section] = {}
for option in config.options(section):
dict[section][option] = config.get(section, option)
return dict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment