import inspect


def is_mod_function(mod, func):
    """Return True if the function is defined within the module_name

    This is useful to distinguish between function defined in the module
    and function imported from another module.
    """
    return inspect.isfunction(func) and inspect.getmodule(func) == mod