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)
Return whether obj is an exception.

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

    
recipes/Python/580808_Guard_against_exceptiwrong/recipe-580808.py