def assert_variable_type(variable, expected_type, raise_exception=True):
    if not isinstance(expected_type, list):
        expected_type = [expected_type]
    for t in expected_type:
        if not isinstance(t, type):
            raise ValueError('expected_type argument "%s" is not a type' %str(t))
    if not isinstance(raise_exception, bool):
        raise ValueError('raise_exception argument "%s" is not a bool' %str(raise_exception))
    if not len([(t) for t in expected_type if isinstance(variable, t)]):
        error_message = '"%s" is not an instance of type %s. It is of type %s' %(str(variable),' or '.join([str(t) for t in expected_type]), str(type(variable)))
        if raise_exception:
            raise ValueError(error_message)
        else:
            return False, error_message
    return True, None