dtlibs.xitertools

dtlibs.xitertools.compact(it)

Iterate through a sequence, skipping duplicates.

>>> seq = 'MINIMUM'
>>> print([i for i in compact(seq)])
['M', 'I', 'N', 'U']
dtlibs.xitertools.group(iterable, size, test)

Group items in iterable in tuples of size if test is True.

Each consecutive slice of size items of iterable are tested by calling test(items). It test returns true, then they are grouped in a tuple.

>>> def ends_with_list(items):
...     return isinstance(items[1], list)
>>> [i for i in group([1, [2, 3], 4, 5, [6, 7, 8]], 2, ends_with_list)]
[(1, [2, 3]), 4, (5, [6, 7, 8])]