I am trying to have different ways to access the same variable. I have a bunch of objects that I store in a dict so I can iterate over them. But on occcasion I would like to access them directly (without going through the structure in the dict...)
object1 = someObjectContructor()
someDict = {}
someDict[1] = object1
Can I have the two point to the same object in memory? So that if I change something in object1 that change would be there in the the dictionary?
someDict, one inobject1. Modifying one will modify the other. However, assigning a new value to either will break the link.object1been a string, for instance, the answer would have been different, as strings are immutable in Python. You can verify that two objects are identical with theidfunction (and also theisstatement).Coverage) on when python refers to the same objects and when not. Hope this helps!