Just for curiosity.. python "variables" are references to objects. Each has a name or "accesser label" so I can refer to them while scripting.
Does each python object keep a list of all "variable names" refering to itself? How would I access it?
# A random object
class A(object):
pass
# references to instances
a = A()
b = A()
c = a
# I happen to come accross one reference
ref = c
# This is how I find all the ways I can access it
# i.e. all its "accessers" or "variable names"
k, v = None, None # to avoid `RuntimeError: dictionary changed size..`
for k, v in globals().items():
if v is ref:
print(k) # prints "a c ref" since `a is c` and `c is ref`
# Is there a way I may get this without looping over all variables? Like a..
ref.__getallreferencenames__() # AttributeError
# Is that information stored and kept up to date somewhere?