Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > how to write special value to a config file with ConfigParser

Thread Tools

how to write special value to a config file with ConfigParser

Posts: n/a

I found it easy to read configures from a config file.
But how can I set a special value to an item or write it into the
original file?
I have tried this:

import ConfigParser
config = ConfigParser.ConfigParser()'a.conf')
config.get('Main', 'Something') # That is OK.
config.set('Main', 'Something', '2') # without any fault
#fp = open('a.conf') # can not be done, raise Error
#fp = open('a.conf', 'a') # Something set to 2, but it copies the all items

# How can I do it?

Reply With Quote
Posts: n/a

I have tried this:

import ConfigParser
fp = file("test.conf","w+")
cp = ConfigParser.ConfigParser()

and works fine for me.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Config & ConfigParser Chuck Python 11 03-07-2013 04:18 PM
ConfigParser: Can I read(ConfigParser.get()) a configuration file anduse it to call a funciton? Python 3 06-26-2008 08:01 PM
Any other config parsing modules besides ConfigParser ? Arthur Pemberton Python 2 05-29-2006 03:40 PM
[ConfigParser] value with ; and the value blank kai Python 1 05-05-2006 05:18 PM