-
Notifications
You must be signed in to change notification settings - Fork 16
/
USAGE.TXT
31 lines (21 loc) · 834 Bytes
/
USAGE.TXT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1) Dictionaries with mixed depth of nested levels:
(Only works well for scalars)
nd= nested_dict()
nd["mouse"]["chr1"]["+"] = 311
nd["mouse"]["chromosomes"]="completed"
nd["mouse"]["chr2"] = "2nd longest"
nd["mouse"]["chr3"] = "3rd longest"
nd["human_chromosomes"] = "to be done"
2) Dictionaries with pre-determined levels of nesting, and type of the contained value:
(Especially useful for containers)
# two levels of nesting
nd2 = nested_dict(2, list)
nd2["mouse"]["chr2"].append(12)
# three levels of nesting
nd3 = nested_dict(3, set)
nd3["mouse"]["chr2"]["categorised"].add(3)
# counts
nd4 = nested_dict(2, int)
nd4["mouse"]["chr2"]+=4
nd4["human"]["chr1"]+=3
nd4["human"]["chr3"]+=4