469,362 Members | 2,470 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,362 developers. It's quick & easy.

Question re ConfigParser

Given a section like

[Data]
value1
value2
value3
Can ConfigParser be easily used to put the values in a dictionary? If
so, how?


Aug 20 '08 #1
2 758
On Aug 20, 5:34*pm, loial <jldunn2...@googlemail.comwrote:
Given a section like

[Data]
value1
value2
value3

Can ConfigParser be easily used to put the values in a dictionary? If
so, how?
Dictionaries are key/value pairs. Do you expect 'value1' to be a key
or a value?

If the data is literally as you describe, and not key/value entries
(such as 'key1: value1' or 'key1=value1'), you would probably be
better off just stepping through the file, testing for the [data]
section and then reading the following lines into a list.
Aug 20 '08 #2
On 20 Aug, 13:49, alex23 <wuwe...@gmail.comwrote:
On Aug 20, 5:34*pm, loial <jldunn2...@googlemail.comwrote:
Given a section like
[Data]
value1
value2
value3
Can ConfigParser be easily used to put the values in a dictionary? If
so, how?

Dictionaries are key/value pairs. Do you expect 'value1' to be a key
or a value?

If the data is literally as you describe, and not key/value entries
(such as 'key1: value1' or 'key1=value1'), you would probably be
better off just stepping through the file, testing for the [data]
section and then reading the following lines into a list.
Thanks. Thats what I did in the end
Aug 21 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Greg Krohn | last post: by
2 posts views Thread by Roy H. Berger | last post: by
2 posts views Thread by rzed | last post: by
1 post views Thread by pipehappy | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.