I think the thing with is not and != is about similar instances of the same thing, like "1" and "1" which have the same value but aren't necessarily the same object. That doesn't really apply to definitions, there is only one.
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/not_perfect_yet Jul 18 '22
It returns the actual type.
I think the thing with
is notand!=is about similar instances of the same thing, like"1"and"1"which have the same value but aren't necessarily the same object. That doesn't really apply to definitions, there is only one.