I found the way to make a list filled with the same literal.
So I did following:
my_list_of_dict = [{}] * 3
my_list_of_dict[0][0] = 1
my_list_of_dict[0][1] = 2
print(my_list_of_dict)
# What I thought : [{0: 1, 1: 2}, {}, {}]
# What actually happened : [{0: 1, 1: 2}, {0: 1, 1: 2}, {0: 1, 1: 2}]
Is this a bug? or an intended feature?
It seems like python doesn't initialize new dict every time but just assigning given dict to the list.
Plus, How do I call(pronouce) [] * n
? is this a kind of list comprehension?