I have the following:
config = ConfigParser() config.read(\'connections.cfg\') sections = config.sections()
How can I close the file opened
Use readfp instead of read:
with open('connections.cfg') as fp: config = ConfigParser() config.readfp(fp) sections = config.sections()