jweinst1
10/20/2015 - 7:40 PM

Get's a dictionary of functions from a module. Can be used for classes too.

Get's a dictionary of functions from a module. Can be used for classes too.

import importlib
import types

def getfuncs(modulename):
    retval = {}
    opened = importlib.import_module(modulename)
    for name in opened.__dict__.keys():
        if isinstance(opened.__dict__[name], types.FunctionType):
            retval[name] = opened.__dict__[name]
    return retval