[Tutor] An example of ConfigParser module usage please....
karthik Guru
karthikg@aztec.soft.net
Thu, 29 Nov 2001 20:01:49 +0530
I got it!! thanks.
Let me just post it if it c'd be of some use to a fellow newbie!
This is what i had in the conf.txt file
---------
[server]
database:octago
user:sa
password:blank
[personal]
name:karthik
age:21
company:Aztec
---------
'personal' and 'server' are the sections.
config = ConfigParser.ConfigParser()
config.add_section("server")
config.add_section("personal")
//read the conf file
fname = open("conf.txt","r")
config.readfp(fname)
print config.get("server","database") // under the server section get the
value for the database key
>> octago
print config.get("personal","name")
>>karthik
python is fun and simple :-)