macpie.itertools.filter_get_index#

macpie.itertools.filter_get_index(predicate, iterable)#

Make an iterator that yields items of iterable for which predicate returns true, along with the index of that item.

Returns an iterator of 2-tuples, where the first value is the item that returned true, and the second value is the index of that item.

>>> seq = ['a', 'b', 3, 'b', 'd']
>>> nums = filter_get_index(lambda x: isinstance(x, int), seq)
>>> next(nums)
(3, 2)