-1

I am trying to check if two python objects have same memory address

I am trying to do somthing like a == b. but its not working.

Ankita
  • 11
  • 2
  • 7
    Does this answer your question? [How do I check if two variables reference the same object in Python?](https://stackoverflow.com/questions/3647546/how-do-i-check-if-two-variables-reference-the-same-object-in-python) – Łukasz Ślusarczyk Aug 05 '20 at 13:45

1 Answers1

0

you can use id to know if they refere to the same object.

a= 5
b= 4+1

print (id(a))
print (id(b))

Compare if two variables reference the same object in python

How do I check if two variables reference the same object in Python?

Alex
  • 37
  • 9