Esempio n. 1
0
def first(predicate, it):
    """Returns the first element in `iterable` that `predicate` returns a
    :const:`True` value for.

    If `predicate` is None it will return the first item that is not None.

    """
    return next((v for v in it if (predicate(v) if predicate else v is not None)), None)
Esempio n. 2
0
def first(predicate, it):
    """Returns the first element in `iterable` that `predicate` returns a
    :const:`True` value for.

    If `predicate` is None it will return the first item that is not None.

    """
    return next(
        (v for v in it if (predicate(v) if predicate else v is not None)),
        None,
    )
 def errback(self, exc, intervals, retries):
     interval = next(intervals)
     sleepvals = (None, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 16.0)
     self.index += 1
     self.assertEqual(interval, sleepvals[self.index])
     return interval
Esempio n. 4
0
 def errback(self, exc, intervals, retries):
     interval = next(intervals)
     sleepvals = (None, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 16.0)
     self.index += 1
     self.assertEqual(interval, sleepvals[self.index])
     return interval