Trying to display data in a structure that is a dictionary contained in a defaultdict
dictionary=defaultdic(dict)
Example
defaultdict = {key1} :
{subkey1}:
(val1,
val2,
val3)
{subkey2}:
(val4,
val5,
val6)
{key2} :
{subkey3}:
(val7,
val8,
val9),
{subkey4}:
(val10,
val11,
val12)
I tried to do
for key in dictionary.iterkeys():
print key # This will return me the key
for items in dictionary[key]:
print items # This will return me the subkey
for values in dictionary[key][items]:
print values #this return the values for each subkey)
The problem is that I just get printed out a flat list of items; which is almost impossible to follow when you have too many items and keys.
How do you properly print such complex structures, to present them in a way that does not make you rip your eyes out? I tried with pprint and json.dumps but neither was making the situation better. Ideally I would like to have it printed as in my example, but I can't see a simple way to do so, without going trough complex string manipulation to format the print output.