In Python, None is a singleton, so checking whether a variable is
None may be done with is or is not. This has a slight advantage
over equiality comparisons == None and != None, since __eq__ may
be overridden in Python to produce sometimes unexpected results.
Using is None and is not None is also recommended practice in
https://www.python.org/dev/peps/pep-0008:
Comparisons to singletons like None should always be done with is or
is not, never the equality operators.