If I create a list with an empty dictionary in it, then multiply that list by a number, it seems that instead of adding more dictionaries to the list, python just populates the list with more references to the same dictionary.
>>> d = [{}]*3
>>> d[0]["x"] = 43
>>> d
[{'x': 43}, {'x': 43}, {'x': 43}]
As you can see, adding an element in one of the dictionaries leads to insertion into all of them, which means that there is in fact only one dictionary, with three pointers in d
to it.
Why is this? What is the best way to add a number of empty dicts to a list in Python?