def catch_key_error(what, otherwise):
    """
    runs callable 'what' and catches KeyErrors, 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 KeyError:
        return otherwise
