Skip to content

Instantly share code, notes, and snippets.

@stefanooldeman
Created June 25, 2014 11:59
Show Gist options
  • Save stefanooldeman/7634e68c4d7d88eeffdd to your computer and use it in GitHub Desktop.
Save stefanooldeman/7634e68c4d7d88eeffdd to your computer and use it in GitHub Desktop.
from ConfigParser import ConfigParser
class LoaderConfig(dict):
def __init__(self, config_path, section):
_dyn_kwargs = self.load_config(config_path)
super(LoaderConfig, self).__init__(_dyn_kwargs[section])
self.__dict__ = self
def load_config(self, config_path):
config = ConfigParser()
config.read(config_path)
section_values = config._sections
for key, values in section_values.items():
del section_values[key]['__name__']
return section_values
if __name__ == "__main__":
cnf = LoaderConfig("myfilefooo.conf", "mysql")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment