I needed to create a list of None
objects and used this form
a = [None] *2
a[0] = 0
the value of a
was:
[1, None]
however, when i tried the same thing with:
a = [{'elem' : 0}] * 2
and after that
a[1]['elem'] = 0
the value of a
became:
[{'elem': 1}, {'elem': 1}]
can anyone help me understand the mechanism behind this?