Last active
June 27, 2017 21:06
-
-
Save giuserpe/1da7b5afcbcb229b7387a1898c7e38ef to your computer and use it in GitHub Desktop.
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
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment