def first_that(predicate, sequence, message=None):
    """The first item in that sequence that matches that predicate

    If none matches raise a KeyError with that message
    """
    try:
        return next(ifilter(predicate, sequence))
    except StopIteration:
        raise KeyError(message or 'Not Found')
def first_that ( predicate , sequence , message = None ) : try : return next ( ifilter ( predicate , sequence ) ) except StopIteration : raise KeyError ( message or 'Not Found' )
The first item in that sequence that matches that predicate

    If none matches raise a KeyError with that message