You Are Here:

Community: Developer Discussion Boards

#1 Old ConfigObj - 2008-08-22, 12:59

Join Date: Jun 2008
Posts: 8
Take0n
Offline
Registered User
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
Reply With Quote

#2 Old Re: ConfigObj - 2008-08-22, 15:31

Join Date: Jun 2008
Posts: 73
Whirlwind
Offline
Regular Contributor
I lose the module. :-(
Can you link it for me?

Thanks.
Whirlwind
Reply With Quote

#3 Old Re: ConfigObj - 2008-08-22, 15:43

Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
bogdan.galiceanu's Avatar
bogdan.galiceanu
Offline
Forum Nokia Champion
Quote:
Originally Posted by Whirlwind View Post
I lose the module. :-(
Can you link it for me?

Thanks.
Whirlwind
Here it is: http://www.voidspace.org.uk/python/configobj.html
Reply With Quote

#4 Old Re: ConfigObj - 2008-08-22, 15:44

Join Date: Jun 2008
Posts: 8
Take0n
Offline
Registered User
Yes, I found it over at sourceforge here is the link:

http://sourceforge.net/projects/configobj

I just took the configobj.py file and put it in E:\
Reply With Quote

#5 Old Re: ConfigObj - 2008-08-22, 15:48

Join Date: Jun 2008
Posts: 8
Take0n
Offline
Registered User
The code I am using is pretty the same as the one in their example but I don't get why it won't work for me :\
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia