There are "==" and "is" as a method to compare objects, but I didn't know how to use them properly, so I summarized the differences.
Compare whether object 1 and object 2 are equivalent. Equivalence means "does it have the same value?"
test01.py
object1=100
object2=100
if object1 == object2 :
print("Equivalent")
else :
print("Not equivalent")
#Output: Equivalent
In test01.py, object1 and object2 have the same value (int type 100), so the if statement is evaluated as True.
test02.py
object1=100 #int type 100
object2="100" #str type 100
if object1 == object2 :
print("Equivalent")
else :
print("Not equivalent")
#Output: not equivalent
Since test02.py compares "int type 100" and "str type 100", the if statement is evaluated as False.
"Is" checks "whether the compared objects are the same object".
test3.py
object1=[1,2,3]
object2=[1,2,3]
print(object1 is object2)
print(object1 is object1)
#output
#False
#True
When an object is created, an id number (unique number) is assigned to the object. "Is" compares this id to see if they are the same object. The id number can be found with the id method.
test04.py
object1=[1,2,3]
object2=[1,2,3]
print(id(object1)) #id()Look up the id number of that object with
print(id(object2))
print(object1 is object2)
print(object1 is object1)
#output
#4488767496 (id number of object1)
#4488768392 (id number of object2)
#False
#True
"==" Checks if the compared objects are equivalent. "Is" checks if the ids of the compared objects are equivalent.