1 2 3 4 5 6 7 8 9 10 11 12 13
import configparser import sys iniConfig = configparser.ConfigParser() iniConfig.read('config.ini') try: iniConfig['DATABASE'] except KeyError: try: iniConfig.read("../config.ini") except KeyError: iniConfig.read("../../config.ini")