I'm having a problem using dictionaries of dictionaries, that can be described by the code below:
Dic_A = {}
Dic_B = {}
Dic_A["A1"] = "1"
Dic_A["A2"] = "2"
Dic_B["AA"] = Dic_A
print "Dic_B after : " + str(Dic_B)
Dic_A["A1"] = "4"
Dic_A["A2"] = "5"
print "Dic_B before: " + str(Dic_B)
Dic_B["AB"] = Dic_A
print "Dic_B after : " + str(Dic_B)
The output I get is:
Dic_B after : {'AA': {'A1': '1', 'A2': '2'}}
Dic_B before: {'AA': {'A1': '4', 'A2': '5'}}
Dic_B after : {'AA': {'A1': '4', 'A2': '5'}, 'AB': {'A1': '4', 'A2': '5'}}
Why is Dic_B["AA"] updated when I update Dic_A? And how do I get around this problem?
Thanks in advance :-)
Nick