It seems that the meaning is slightly different from "==". "is" is an exact match including the type.
print(1 == True) # True
print(1 is True) # False
Also, differences can be seen in the comparison between sequences.
li = [1,2,3]
st = [1,2,3]
print(li == st) # True
print(li is st) # False
By the way, I used to post a similar post in Javascript. http://qiita.com/juniskw/items/4a1f4d91fdf759e6a3da
Even if the two arrays have the same value, they seem to be different objects, so it seems that there is a difference. Does "==" simply compare values and "is" compares the objects themselves?
Or rather, I noticed it for the first time, but it seems that the meaning is slightly different between Python and Javascript even if it is the same "==".
Recommended Posts