Revision 7007
Added by Aaron Marcuse-Kubitza about 12 years ago
lib/lists.py | ||
---|---|---|
1 | 1 |
# Lists |
2 | 2 |
|
3 |
import operator |
|
4 |
|
|
3 | 5 |
def is_seq(value): |
4 | 6 |
return (isinstance(value, list) or isinstance(value, tuple) |
5 | 7 |
or isinstance(value, set)) |
... | ... | |
13 | 15 |
try: list_.pop() |
14 | 16 |
except IndexError: break |
15 | 17 |
|
18 |
def and_(list_): return reduce(operator.and_, map(bool, list_), True) |
|
19 |
|
|
20 |
def or_(list_): return reduce(operator.or_, map(bool, list_), False) |
|
21 |
|
|
16 | 22 |
def uniqify(list_): |
17 | 23 |
'''Removes duplicates from an iterable. Preserves order.''' |
18 | 24 |
existing = set() |
Also available in: Unified diff
lists.py: Added and_(), or_()