How can I get around this limitation:
>>> test_dict = dict.fromkeys(['k1', 'k2'], dict())
>>> test_dict['k1']['sub-k1'] = 'apples'
>>> test_dict
{'k2': {'sub-k1': 'apples'}, 'k1': {'sub-k1': 'apples'}}
I want each of the keys k1
and k2
to have a new dictionary instance, not the same one.