472,142 Members | 1,206 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,142 software developers and data experts.

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 793
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.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.