def ensure_instance(value, types):
    """
    Ensure value is an instance of a certain type

    >>> ensure_instance(1, [str])
    Traceback (most recent call last):
    TypeError:

    >>> ensure_instance(1, str)
    Traceback (most recent call last):
    TypeError:

    >>> ensure_instance(1, int)
    >>> ensure_instance(1, (int, str))

    :attr types: Type of list of types
    """
    if not isinstance(value, types):
        raise TypeError('expected instance of {}, got {}'.format(types, value))
