I would like to get the first item from a list matching a condition. It\'s important that the resulting method not process the entire list, which could be quite large. For e
The itertools module contains a filter function for iterators. The first element of the filtered iterator can be obtained by calling next() on it:
next()
from itertools import ifilter print ifilter((lambda i: i > 3), range(10)).next()