user5506560 user5506560 - 1 year ago 79
Python Question

Get a list from config.ini file

In my config file I have something like that :


Now, I would like to process it in my main file as normal lists :

config = configparser.ConfigParser()"configTab.ini")
for index in range(len(List)):

Now when I read from configuration file "List" is a normal String.
What is the best approach to to it?

If I put a normal list variable in my main code it this way:


Then it works fine, but I would like to get that from my configure file,


Answer Source

Use str.split:

List = List.split(',')

string = 'a, b, c'
>> ['a', 'b', 'c']
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download