def is_exception(obj):
    """Return whether obj is an exception.

    >>> is_exception(ValueError)  # An exception class.
    True
    >>> is_exception(ValueError())  # An exception instance.
    True
    >>> is_exception(float)
    False

    """
    try:
        return issubclass(obj, BaseException)
    except TypeError:
        return isinstance(obj, BaseException)