示例#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)
示例#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
示例#4
0
文件: test_utils.py 项目: 66ru/kombu
 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