root/lib/lists.py @ 2545
1 | 1883 | aaronmk | # Lists
|
---|---|---|---|
2 | |||
3 | def is_seq(value): return isinstance(value, list) or isinstance(value, tuple) |
||
4 | 2415 | aaronmk | |
5 | def uniqify(list_): |
||
6 | '''Removes duplicates from a list. Preserves order.'''
|
||
7 | existing = set() |
||
8 | new_list = [] |
||
9 | for value in list_: |
||
10 | if value not in existing: |
||
11 | existing.add(value) |
||
12 | new_list.append(value) |
||
13 | return new_list |