0

I have a config file with the below section


[TEST]

fruit=["apple","select * from apple"]
vegetable=["carrot","select * from carrot"]

I am trying to load the section into a python dictionary using the below code

   config=ConfigParser.RawConfigParser()
   config.optionxform =str
   cofigPath='/home/ini/target.ini'
   config.read(configPath)

Now , when i am trying to load the section into a dictionary , i am not getting the list in the value , instead its getting stored as a String

   tabList=dict(config.items('TEST'))
   for k, v in tableList.iteritems():
       print(k,v[0])

The v[0] is not printing "apple" , instead its taking the value section of teh dictionary as a string and printing v[0] as "[" , the first character of the value of the dictionary.

Please suggest what i should incorporate to read the section into dictionary where i can get the list as the value when i iterate over the dictionary

user2717470
  • 257
  • 1
  • 5
  • 15

0 Answers0