I just spent an hour with the following frustration, and
a) wanted to post it in case someone else has the same problem, and b) i am very curious what underlies this behavior.
$ e = [{}]*6
$ e
[{}, {}, {}, {}, {}, {}]
$ e[0]['green'] = 'blue'
$ e
[{'green': 'blue'}, {'green': 'blue'}, {'green': 'blue'}, {'green': 'blue'}, {'green': 'blue'}, {'green': 'blue'}]
$ e = [{}, {}, {}, {}, {}, {}]
$ e
[{}, {}, {}, {}, {}, {}]
$ e[0]['green'] = 'blue'
$ e
[{'green': 'blue'}, {}, {}, {}, {}, {}]
Basically, the problem is when a list of dictionaries is initialized with [{}]*int, attempts to modify a single dictionary by its index in the list modifies all dictionaries. Whereas explicitly initializ
Thanks