def get_callable_from_string(f_name):
    try:
        mod_name, func_name = get_mod_func(f_name)
        if mod_name == "" and func_name == "":
            raise AttributeError("%s couldn't be converted to a module or function name" % f_name)

        module = __import__(mod_name)

        if func_name == "":
            func_name = mod_name # The common case is an eponymous class

        return getattr(module, func_name)

    except (ImportError, AttributeError), exc:
        raise RuntimeError("Unable to create a callable object for '%s': %s" % (f_name, exc))
Takes a string containing a function name (optionally module qualified) and returns a callable object
dataset/ETHPy150Open nigelkersten/pymacadmin/bin/crankd.py/get_callable_from_string