I'm trying to make a list of defaultdicts, each with their own unique lambda. This works perfectly fine if I do the indexing by hand, eg
lambda_dictlist.append(defaultdict(lambda: default_values[0], original_dictlist[0]))
lambda_dictlist.append(defaultdict(lambda: default_value[1], original_dictlist[1]))
etc...
However, once I put this in a forloop as follows:
for i in range(len(original_dictlist)):
lambda_dictlist.append(defaultdict(lambda: default_values[i], original_dictlist[i]))
each iteration, the newest default value overwrites the original default values. This overwrite is to the level of the actual id, as the id of the lambda changes from the original value to the id to the id of the most recent lambda.