unique_everseen

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

Yields unique elements in iterable, preserving order, remembering all elements ever seen.

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

element in iterable

Examples

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