from configparser import RawConfigParser config = RawConfigParser() config.read( filenames='./config.ini', ) class Database: host = config.get( section='Database', option='host', fallback='localhost', ) user = config.get( section='Database', option='user', ) password = config.get( section='Database', option='password', fallback='', ) dbname = config.get( section='Database', option='dbname', )