Configfile

F

Fulvio

***********************
Your mail has been scanned by InterScan MSS.
***********************


HI,

I've a small doubt regarding the way to save a configuration file on the file
manipulated by ConfigParser.
As far as I could understand this:

cp = ConfigParser.ConfigParser
cp.set(section,option)

will it do the set on the file or do I have to issue a "cp.write(fp)" in order
to get it done?
My tests didn't resulted positively.

F
 
D

Diez B. Roggisch

Fulvio said:
***********************
Your mail has been scanned by InterScan MSS.
***********************


HI,

I've a small doubt regarding the way to save a configuration file on the file
manipulated by ConfigParser.
As far as I could understand this:

cp = ConfigParser.ConfigParser

You are missing a () here....
cp.set(section,option)

will it do the set on the file or do I have to issue a "cp.write(fp)" in order
to get it done?
My tests didn't resulted positively.

What does that mean? Did your head explode, has a giant mammoth stomped
your PC into oblivion, or has by any chance an exception occured that
you don't show us?

I guess you've been told to read this here, but just in case it wasn't,
or you didn't bother to read it:

http://catb.org/esr/faqs/smart-questions.html

Diez
 
L

Larry Bates

Fulvio said:
***********************
Your mail has been scanned by InterScan MSS.
***********************


HI,

I've a small doubt regarding the way to save a configuration file on the file
manipulated by ConfigParser.
As far as I could understand this:

cp = ConfigParser.ConfigParser
cp.set(section,option)

will it do the set on the file or do I have to issue a "cp.write(fp)" in order
to get it done?
My tests didn't resulted positively.

F
Yes you have to get a file pointer (fp) and do the write as you noted.

Also to get instance of ConfigParser you need:

cp = ConfigParser.ConfigParser() (note the trailing parenthesis)

If you want to read existing .INI file before doing this you need a
cp.read('filename.ini') somewhere in your code.

-Larry
 
L

Larry Bates

Fulvio said:
***********************
Your mail has been scanned by InterScan MSS.
***********************


HI,

I've a small doubt regarding the way to save a configuration file on the file
manipulated by ConfigParser.
As far as I could understand this:

cp = ConfigParser.ConfigParser
cp.set(section,option)

will it do the set on the file or do I have to issue a "cp.write(fp)" in order
to get it done?
My tests didn't resulted positively.

F
Yes you have to get a file pointer (fp) and do the write as you noted.

Also to get instance of ConfigParser you need:

cp = ConfigParser.ConfigParser() (note the trailing parenthesis)

If you want to read existing .INI file before doing this you need a
cp.read('filename.ini') somewhere in your code.

-Larry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top