def parse_flag(exception_message):
    """
    Parse the flag from the solver exception.
    e.g.

    >>> parse_flag("Exception: Dopri5 failed with flag -3")
    -3

    :param exception_message: message from the exception
    :type exception_message: str
    :return: flag id
    :rtype: int
    """
    import re
    match = re.match('.* failed with flag (-\d+)', exception_message)
    try:
        return int(match.group(1))
    except Exception:
        return None
def parse_flag ( exception_message ) : import re match = re . match ( '.* failed with flag (-\d+)' , exception_message ) try : return int ( match . group ( 1 ) ) except Exception : return None
Parse the flag from the solver exception.
    e.g.

    >>> parse_flag("Exception: Dopri5 failed with flag -3")
    -3

    :param exception_message: message from the exception
    :type exception_message: str
    :return: flag id
    :rtype: int