from configparser import ConfigParser import os conf = ConfigParser() ini_file = os.path.dirname(__file__) + "/fioul.ini" try: conf.read_file(open(ini_file)) except FileNotFoundError: print("Configuration file 'fioul.ini' not found") print("Please take a look at 'fioul.ini.example' to create one") exit(42)