The function below works in Python 3.4 - it is used to load and run specific functions in modules, but you need to add the folder to the sys path.
sys.path.append("path_to_your_file_to_import")
tool = {'file':'test_tool.py',
'function':'sum_even_numbers',
'args':['list'],
'return':['int']
}
args = [1,2,3]
def run(tool, args, silent='Y'):
if silent == 'N':
print('main called ' + tool['file'] + '->' + tool['function'] + ' with ', args, ' = ', tool['return'])
mod = __import__( os.path.basename(tool['file']).split('.')[0])
func = getattr(mod, tool['function'])
tool['return'] = func(args)
return tool['return']
Call it via
run(tool, args)