|
From: Antonis P. <ant...@gm...> - 2008-08-26 17:18:55
|
Hello
I have an .ini (settings file) which contains following:
Code:
[section1]
item1=value
item2=value
[section2]
item3=value
I put the "test.ini" and the "configobj.py" files in "E:\".
I then run the following script (iniread.py):
Code:
import sys
sys.path.append("E:\\")
import configobj
from configobj import ConfigObj
config = ConfigObj("test.ini")
section = config['section2']
value = section['item3']
print 'item3 : ' + value
But I get the following error:
Quote:
Traceback (most recent call last):
File "C:\private\2000b1a5\default.py", line 81, in menu_action
f()
File "C:\private\2000b1a5\default.py", line 65, in query_and_exec
execfile(script_list[index][1]. encode('utf-8'), script_namespace. namespace)
File "C:\python\iniread.py", line 8, in ?
section = config['section2']
File "E:\configobj.py", line 580, in __getitem__
val = dict.__getitem__(self, key)
KeyError: section2
What am I doing wrong? Why can't I see the value of item3?
I also want to know how to read a file that is not in the same folder
as configobj.py I tried with E:\\foldername\test.ini but I got a parse
error in configobj.py...
Thank you
|