By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,512 Members | 3,689 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,512 IT Pros & Developers. It's quick & easy.

editing a config file

P: n/a
I need to edit the value(s) of a config file via a GUI interface. I'm
trying to use ConfigParser but set() doesn't seem to write.

Here are my reading and writing functions

def getConfig(self,value=None):
config = ConfigParser.ConfigParser()
config.readfp(open('config.inf'))
return config.defaults()[value]

def setConfig(self, option, value):
config = ConfigParser.ConfigParser()
config.readfp(open('config.inf', 'a'))
config.set("DEFAULT", option, value)

The values are getting passed ok it just won't set the value to the
new value i have selected.

can anyone offer any hints?
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Mike Zupan wrote:
I need to edit the value(s) of a config file via a GUI interface.
I'm trying to use ConfigParser but set() doesn't seem to write.

Here are my reading and writing functions

def getConfig(self,value=None):
config = ConfigParser.ConfigParser()
config.readfp(open('config.inf'))
return config.defaults()[value]

def setConfig(self, option, value):
config = ConfigParser.ConfigParser()
config.readfp(open('config.inf', 'a'))
config.set("DEFAULT", option, value)

The values are getting passed ok it just won't set the value to the
new value i have selected.

can anyone offer any hints?


Maybe you're simply missing a config.write('config.inf')?

Mathias
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.