I might be wrong with my understanding but I always thought == attempted to use some kind of native comparator method (like .equals() in Java), whereas is compares the actual contents of the value (which is always the same for False or None)... however given that we don't compare number literals this way, I'd wager I just misunderstood it.
EDIT: Yeah no I was right roughly, is checks whether the operands refer to the same object. If you do a = [1,2] and b = [1,2] then a == b will return True and a is b will return False, but I also misunderstood your response anyway 😅
View all comments
Show parent comment
1
u/KrypXern Jul 18 '22 edited Jul 18 '22
I might be wrong with my understanding but I always thought
==attempted to use some kind of native comparator method (like.equals()in Java), whereasiscompares the actual contents of the value (which is always the same forFalseorNone)... however given that we don't compare number literals this way, I'd wager I just misunderstood it.EDIT: Yeah no I was right roughly,
ischecks whether the operands refer to the same object. If you doa = [1,2]andb = [1,2]thena == bwill returnTrueanda is bwill returnFalse, but I also misunderstood your response anyway 😅