class conf: def __init__(self): config = configparser.SafeConfigParser() config.read(path) #~ pass def w(self, path, section, option, value): """ http://www.programcreek.com/python/example/1033/ConfigParser.SafeConfigParser Write the specified Section.Option to the config file specified by path. Replace any previous value. If the path doesn't exist, create it. Also add the option the the in-memory config. """ #~ config = configparser.SafeConfigParser() #~ config.read(path) if not config.has_section(section): config.add_section(section) config.set(section, option, value) fp = open(path, 'w') config.write(fp) fp.close() def r(self, path, section, option): '''https://pymotw.com/2/ConfigParser/''' #~ config = configparser.SafeConfigParser() #~ config.read(path) return config.get(section, option)