unique_justseen

sknano.core.itertools.unique_justseen(iterable, key=None)[source] [edit on github][source]

Yields unique elements in iterable, preserving order, remembering only the element just seen.

Parameters:
  • iterable (Iterable) –
  • key ({None, callable}, optional) –
Yields:

element in iterable

Examples

>>> list(unique_justseen('AAAABBBCCDAABBB'))
['A', 'B', 'C', 'D', 'A', 'B']
>>> list(unique_justseen('ABBCcAD', str.lower))
['A', 'B', 'C', 'A', 'D']