def enforce_is_callable(var, error_msg):
    """
    Raises an exception with provided error_msg if the variable
    is not a callable.
    """
    if not callable(var):
        raise TypeError(error_msg)
    return var