0

(The idea is simple but I don't know if it is possible or how to do it in Python) Like:

x = 5
y = id(x)
print(#value_at_y)

print should return 5, which is the value at address y i.e. id(x)

AanisNoor
  • 53
  • 4
  • see https://stackoverflow.com/questions/14257350/how-to-access-variable-by-id – balderman Sep 18 '20 at 08:42
  • Does this answer your question? [Can I get a python object from its memory address?](https://stackoverflow.com/questions/15748980/can-i-get-a-python-object-from-its-memory-address) – jrmylow Sep 18 '20 at 08:42

1 Answers1

1

You must use a dictionary. See below:

y={}

for each x add x and its id(x) to y, like below:

y[x]=id(x)

And you can call them later with

y[x]
IoaTzimas
  • 10,538
  • 2
  • 13
  • 30