thanks ichabod801 now almost everything is perfectly clear :) stupidly i thought that the reference you were talking about was referred to the list and not to the dict, now i understand it was a general explanation about how python works
i re adapted the example of @Windspar to my case
i guess that the pro of the shallow copy is that the code is faster and one cons could be that it bring newby like me to this error :P
i have a doubt, from wikipedia says under the voice shallow copy: The referenced objects are thus shared, so if one of these objects is modified (from A or B), the change is visible in the other. Why in my case i didn't need a deep copy? and how it is possible that a shallow copy worked? is there any difference between a shallow copy and a "reference-copy"?
i re adapted the example of @Windspar to my case
a = {'a':1,'b':2,'c':3} b = a c = a.copy() # shallow copy print(a) print(b) print(c) print() a['a'] = 6 b['b'] = 5 c['c'] = 7 print(a) print(b) print(c)now i am only confused by all these term that for me are completely news: copy, shallow copy and deep copy
i guess that the pro of the shallow copy is that the code is faster and one cons could be that it bring newby like me to this error :P
i have a doubt, from wikipedia says under the voice shallow copy: The referenced objects are thus shared, so if one of these objects is modified (from A or B), the change is visible in the other. Why in my case i didn't need a deep copy? and how it is possible that a shallow copy worked? is there any difference between a shallow copy and a "reference-copy"?