I have the following:
config = ConfigParser() config.read(\'connections.cfg\') sections = config.sections()
How can I close the file opened
To test your suspicion, use ConfigParser.readfp() and handle opening and closing of the file by yourself. Make the readfp call after the changes are made.
readfp
config = ConfigParser() #...on each change fp = open('connections.cfg') config.readfp(fp) fp.close() sections = config.sections()