Created
March 8, 2014 17:46
-
-
Save curzona/9435762 to your computer and use it in GitHub Desktop.
Read config file into a dictionary with ConfigParser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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