def is_exception_class(obj):
    """Return whether obj is an exception class, or a tuple of the same.

    >>> is_exception_class(ValueError)
    True
    >>> is_exception_class(float)
    False
    >>> is_exception_class(ValueError())  # An instance, not a class.
    False
    >>> is_exception_class((ValueError, KeyError))
    True

    """
    try:
        if isinstance(obj, tuple):
            return obj and all(issubclass(X, BaseException) for X in obj)
        return issubclass(obj, BaseException)
    except TypeError:
        return False
Return whether obj is an exception class, or a tuple of the same.

    >>> is_exception_class(ValueError)
    True
    >>> is_exception_class(float)
    False
    >>> is_exception_class(ValueError())  # An instance, not a class.
    False
    >>> is_exception_class((ValueError, KeyError))
    True

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