For the purpose of this question I simplified the code but basically I am parsing an oracle table and create a data map of it which I will then use later in the code. I try to save it to a dict of dicts of lists. Instead of getting a dict (e.g. dict['a']['b']) holding a list of tuples I end up having a key referencing a list with only one tuple. Last that got appended.
from collections import defaultdict
somelist = ['a:b:1:2','a:b:3:4','a:b:5:6']
somehash = defaultdict(dict)
for val in somelist:
(a,b,c,d) = val.split(":")
somehash[a] = defaultdict(list)
somehash[a][b].append((c,d))
for i in somehash['a']['b']:
print i
I expect the output to read
('1', '2')
('3', '4')
('5', '6')
Yet I see only
('5', '6')