def slice_after(predicate, iterable):
    """Returns groups of elements from iterable,
    slicing just after predicate(elem) is True
    """
    record = []
    for i, item in enumerate(iterable):
        record.append(item)

        if predicate(item):
            yield tuple(record)
            record = []

    if record:
        yield tuple(record)
def slice_after ( predicate , iterable ) : record = [ ] for i , item in enumerate ( iterable ) : record . append ( item ) if predicate ( item ) : yield tuple ( record ) record = [ ] if record : yield tuple ( record )
Returns groups of elements from iterable,
    slicing just after predicate(elem) is True