I need to parse a dictionary and replace placeholder keys with other values. The dictionary is nested, the placeholder can appear multiple times and at different depths.
Therefore I have written a recursive function which traverses the dict and creates a list of values that belong to keys which are equal to the placeholder.
With this list, I would like to replace the values. This needs reference semantics. It doesn't work:
old={"token":4}
reference=old["token"]
reference=5
print(old["token"]==5) #False
old={"token":4}
references=[]
references.append(old["token"])
references[0]=5
print(old["token"]==5) #False
How can I create references to dictionary entries ?