import configparser import os.path def getConfigurationKey(section, key): config_object = configparser.ConfigParser() config_file = getIniFileForTheEnvironment() with open(config_file,"r") as file_object: config_object.read_file(file_object) parameter=config_object.get(section,key) return formatParameter(parameter) def getIniFileForTheEnvironment(): prodFilePath = "./config/appConfig.ini" devFilePath = "./config/appConfigDEV.ini" if(os.path.isfile(devFilePath)): return devFilePath elif(os.path.isfile(prodFilePath)): return prodFilePath def formatParameter(parameter): formattedParameter = parameter.replace("","=") return formattedParameter a = getConfigurationKey("store", "DefaultHeaders") print(a)