Revision 467
Added by Aaron Marcuse-Kubitza about 13 years ago
lib/util.py | ||
---|---|---|
16 | 16 |
|
17 | 17 |
def rename_key(dict_, orig, new): dict_[new] = dict_.pop(orig) |
18 | 18 |
|
19 |
def dict_subset(dict_, keys): dict([(key, dict_[key]) for key in keys]) |
|
19 |
def dict_subset(dict_, keys): |
|
20 |
subset = dict() |
|
21 |
for key in keys: |
|
22 |
try: subset[key] = dict_[key] |
|
23 |
except KeyError: pass |
|
24 |
return subset |
Also available in: Unified diff
util.py: Fixed dict_subset() to work correctly when a key does not exist