I'm trying to do a hard copy on a dictionary to avoid modifying the values of original one.
Here is my code:
import copy
d1 = {1: 1}
d2 = copy.deepcopy(d1)
d2[1] = None
What if d1 is a ImmutableDict? How can I copy one and allow it to be modified?
import immutabledict
d1 = immutabledict.immutabledict({1: 1})
d2 = copy.deepcopy(d1)
d2[1] = None # TypeError: 'immutabledict' object does not support item assignment