def is_instance_factory(_type):
if isinstance(_type, (tuple, list)):<EOL><INDENT>_type = tuple(_type)<EOL>type_repr = "<STR_LIT:|>".join(map(str, _type))<EOL><DEDENT>else:<EOL><INDENT>type_repr = "<STR_LIT>".format(typ=_type)<EOL><DEDENT>def inner(x):<EOL><INDENT>if not isinstance(x, _type):<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise ValueError(msg.format(type_repr=type_repr))<EOL><DEDENT><DEDENT>return inner<EOL>
Parameters
----------
`_type` - the type to be checked against

Returns
-------
validator - a function of a single argument x , which raises
            ValueError if x is not an instance of `_type`