Revision 1907
Added by Aaron Marcuse-Kubitza almost 13 years ago
lib/dicts.py | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import itertools |
4 | 4 |
|
5 |
import util |
|
6 |
|
|
5 | 7 |
class IdDict(dict): |
6 | 8 |
'''A dict that stores objects by id()''' |
7 | 9 |
|
... | ... | |
21 | 23 |
try: return dict_[key] |
22 | 24 |
except KeyError: pass |
23 | 25 |
raise # reraise last KeyError |
26 |
|
|
27 |
def make_hashable(value): |
|
28 |
if isinstance(value, list): value = tuple(value) |
|
29 |
elif isinstance(value, dict): value = util.NamedTuple(**value) |
|
30 |
return value |
Also available in: Unified diff
dicts.py: Added make_hashable()