from itertools import filterfalse def unique_everseen(iterable, key=None): "List unique elements, preserving order. Remember all elements ever seen." # unique_everseen('AAAABBBCCDAABBB') --> A B C D # unique_everseen('ABBCcAD', str.lower) --> A B C D seen = set() seen_add = seen.add if key is None: for element in filterfalse(seen.__contains__, iterable): seen_add(element) yield element else: for element in iterable: k = key(element) if k not in seen: seen_add(k) yield element
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
__pycache__ | Folder | 0755 |
|
|
__init__.py | File | 29.88 KB | 0644 |
|
_adapters.py | File | 1.82 KB | 0644 |
|
_collections.py | File | 743 B | 0644 |
|
_functools.py | File | 2.83 KB | 0644 |
|
_itertools.py | File | 607 B | 0644 |
|
_meta.py | File | 1.1 KB | 0644 |
|
_text.py | File | 2.15 KB | 0644 |
|