import configparser CONFIG_FILE = "configuration.ini" config = configparser.ConfigParser() config.read(CONFIG_FILE) if config.has_section("DB"): db_conf = config["DB"] else: db_conf = {} MAX_LOGIN_LENGTH = db_conf.get("maxLoginLength", 20)