Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a list from config.ini file

In my config file I have something like that :

[Section_1]
List=Column1,Column2,Column3,Column4

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

    config = configparser.ConfigParser()
    config.read("configTab.ini")
    for index in range(len(List)):
                 sql=sql.replace(List[index],"replace("+List[index]+","'hidden'")")

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:

List=['Column1','Column2','Column3','Column4']

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

Thanks

like image 506
bazyl Avatar asked Sep 15 '25 05:09

bazyl


1 Answers

Use str.split:

List = List.split(',')

string = 'a, b, c'
print(string.split(','))
>> ['a', 'b', 'c']
like image 178
DeepSpace Avatar answered Sep 17 '25 20:09

DeepSpace