Identity (is, is not)
`is` asks whether two names point to the same object; `==` asks whether they hold the same value.
Used in 47 lessons of the course, from 00.02.
a is b gives True only if a and b are the same object in memory. It does not compare contents. To compare contents you use ==.
a is not b is the opposite, and it reads almost like English: "a is not b".
The most common use is with None. There is only one None in the whole program, so x is None is a precise, clear question: "was no value given?". That is why it is preferred over x == None.
In the course you see it in lines like if path is None:, which checks whether the argument arrived empty before using a default value.
x = None
print(x is None)
Don't use is to compare numbers or strings: the result depends on internal details of Python and can't be trusted.
Reach for it when: you need to know whether a value is `None`, or whether two names point to the same object. To compare contents, use `==`.
Examples
Common mistake
a = [1, 2] b = [1, 2] print(a is b)
Why: `is` compares identity, not contents. These are two separate lists, even though they look the same.
How to write it: Use a == b to compare values. Keep is for None.
