Python Copy Through Assignment?
- by Marcus Whybrow
I would expect that the following code would just initialise the dict_a, dict_b and dict_c dictionaries. But it seams to have a copt through effect:
dict_a = dict_b = dict_c = {}
dict_c['hello'] = 'goodbye'
print dict_a
print dict_b
print dict_c
As you can see the result is as follows:
{'hello': 'goodbye'}
{'hello': 'goodbye'}
{'hello': 'goodbye'}
Why does that program give the previous result, When I would expect it to return:
{}
{}
{'hello': 'goodbye'}