3 ms·
A better way: varname = (x for x in l if predicate_with_single_truth_value(x)).next()
by reinhardt 14y ago
A better way:
varname = (x for x in l if predicate_with_single_truth_value(x)).next()
- Estragon 14y agoThat avoids the construction of the list, but doesn't check that the sequence only contains one value, which was the point of the example.