def check_kwargs(allowed, **kwargs):
    """Raise error for keyword arguments not in allowed list/set else return True"""
    assert type(allowed) in {list, set}, ("First argument must be 'allowed' "
        "list/set of keyword argument names")
    for kwarg in kwargs:
        if kwarg not in allowed:
            raise NameError("Unexpected kwarg {0}: allowed kwargs are {1}".format(kwarg, allowed.__str__()))
    return True