I am working with ConfigParser in python and the ini file that I am reading in has a section titled [ClientList] and under that section I have multiple options. All the options have the same name "customer ="
Eample:
[ClientList]
customer = widget1
customer = widget2
customer = widget3
customer = widget4
I am trying to get a list of all the options but have only been able to get the last one to print. Here is the script that I am working with right now and the only thing it provides me is the last option in my list. Is this even possible with ConfigParser and if so can someone help me?
Thanks
Eample:
[ClientList]
customer = widget1
customer = widget2
customer = widget3
customer = widget4
I am trying to get a list of all the options but have only been able to get the last one to print. Here is the script that I am working with right now and the only thing it provides me is the last option in my list. Is this even possible with ConfigParser and if so can someone help me?
Thanks
Code:
# Import Statment
import ConfigParser
import os
# Script Variables
inifile = 'client.ini.txt'
client = {}
# Reading in config file
config = ConfigParser.ConfigParser()
config.read(inifile)
def main():
x = 0
for section in config.sections():
if section == "ClientList":
for option in config.options(section):
client[x] = config.get(section, option)
#print " ", option, "=", config.get(section, option)
print client
x = x+1
if __name__=="__main__":
main()
Comment