Reputation: 1687
Requirements:
Is there a way to achieve this task?
Upvotes: 0
Views: 44
Reputation: 229461
You need to wrap the value in some sort of container.
class Ref:
def __init__(self, v):
self.val = v
And then:
related_to_dict = Ref(10)
special_dict = {0: related_to_dict}
Then it works as desired:
related_to_dict.val = 40
print(special_dict[0].val) # 40
Upvotes: 1