Connecting Tech Pros Worldwide Forums | Help | Site Map

Question re ConfigParser

loial
Guest
 
Posts: n/a
#1: Aug 20 '08
Given a section like

[Data]
value1
value2
value3


Can ConfigParser be easily used to put the values in a dictionary? If
so, how?





alex23
Guest
 
Posts: n/a
#2: Aug 20 '08

re: Question re ConfigParser


On Aug 20, 5:34*pm, loial <jldunn2...@googlemail.comwrote:
Quote:
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.
loial
Guest
 
Posts: n/a
#3: Aug 21 '08

re: Question re ConfigParser


On 20 Aug, 13:49, alex23 <wuwe...@gmail.comwrote:
Quote:
On Aug 20, 5:34*pm, loial <jldunn2...@googlemail.comwrote:
>
Quote:
Given a section like
>
Quote:
[Data]
value1
value2
value3
>
Quote:
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
Closed Thread