unique_justseen¶
-
class
iteration_utilities.
unique_justseen
(iterable, key=None)¶ List unique elements, preserving order. Remember only the element just seen.
- Parameters
- iterableiterable
Iterable to check.
- keycallable or None, optional
If
None
the values are taken as they are. If it’s a callable the callable is applied to the value before comparing it. Default isNone
.
- Returns
- iterablegenerator
An iterable containing all unique values just seen in the iterable.
Examples
>>> from iteration_utilities import unique_justseen >>> list(unique_justseen('AAAABBBCCDAABBB')) ['A', 'B', 'C', 'D', 'A', 'B']
>>> list(unique_justseen('ABBCcAD', str.lower)) ['A', 'B', 'C', 'A', 'D']
-
key
¶ (callable or None) The key function (readonly).
New in version 0.6.
-
lastseen
¶ (any type) The last seen item (readonly).
New in version 0.6.