import configparser
import sys

import accounts

cp = configparser.ConfigParser()
cp.read(accounts.getFile('inf.cfg'))

def get(param, typename='s'):
    param = param.split('.')
    try:
        if typename == 's':
            return cp[param[0]].get(param[1])
        elif typename == 'i':
            return cp[param[0]].getint(param[1])
        elif typename == 'f':
            return cp[param[0]].getfloat(param[1])
        elif typename == 'b':
            return cp[param[0]].getboolean(param[1])
    except KeyError:
        print('Parameter {}.{} does not exist'.format(*param))
        sys.exit()

import configparser
import sys

import accounts

cp = None

def get(param, typename='s'):
    global cp
    if not cp:
        cp = configparser.ConfigParser()
        cp.read(accounts.getFile('inf.cfg'))
    param = param.split('.')
    try:
        if typename == 's':
            return cp[param[0]].get(param[1])
        elif typename == 'i':
            return cp[param[0]].getint(param[1])
        elif typename == 'f':
            return cp[param[0]].getfloat(param[1])
        elif typename == 'b':
            return cp[param[0]].getboolean(param[1])
    except KeyError:
        print('Parameter {}.{} does not exist'.format(*param))
        sys.exit()

Load config on demand