I was (maybe wrongfully) thinking that is
operator is doing id() comparison.
>>> x = 10
>>> y = 10
>>> id(x)
1815480092
>>> id(y)
1815480092
>>> x is y
True
However, with val is not None
, it seems like that it's not that simple.
>>> id(not None)
2001680
>>> id(None)
2053536
>>> val = 10
>>> id(val)
1815480092
>>> val is not None
True
Then, what does 'is' operator do? Is it just object id comparison just I conjectured? If so, val is not None
is interpreted in Python as not (val is None)
?