def catch_attribute_error(what, otherwise):
    """
    runs callable 'what' and catches AttributeError, returning 'otherwise' if one occurred
    :param what: callable
    :param otherwise: alternate result in case of IndexError
    :return: result of 'what' or 'otherwise' in case of IndexError
    """
    try:
        return what()
    except AttributeError:
        return otherwise