Read and write config files in python

import configparser
config = configparser.ConfigParser()

Example conf file:

sendcalendarreminders = False
writeexcelfile = True

billdir = /home/joel/Documents/Bills
excelfilename = creditcarddues.xlsx

prefix_icici = ICICI_
password_icici = mypass

Reading conf file:'~/getcreditcards.conf'))
SendCalendarReminders = config['DEFAULT']['sendcalendarreminders']
WriteExcelFile = config['DEFAULT']['writeexcelfile']
prefix_icici = config['cards']['prefix_icici']

A gotcha you’ve got to remember is that when you read the conf file, everything you get is a string. There are no integers, or booleans. If you want any other data type, you’ve got to convert specifically to that.