itertools.compress(data, selectors)
Make an iterator that filters elements from data returning only those that have a corresponding element in selectors that evaluates to True
. Stops when either the data or selectors iterables has been exhausted. Roughly equivalent to:
def compress(data, selectors): # compress('ABCDEF', [1,0,1,0,1,1]) --> A C E F return (d for d, s in zip(data, selectors) if s)
New in version 3.1.
Please login to continue.