So if I understand correctly, you are doing
>>> not None is False
True
>>> None is True
False
And you are wondering why the second one outputs False
.
This is because not None is False
is the same as not (None is False)
which is not False
which is True
. On the other hand None is True
just evaluates immediately to False
.
On a side note, you seem to think that not None is False
would evaluate as (not None) is False
. However, if this were the case, the result would be False
by this evaulation:
(not None) is False -> True is False -> False
So this can't be the correct interpretation because this is not the result we get.
The key here is to evaluate one piece of an expression at a time. If you are familiar with order of operations (PEMDAS) from math, python has similar rules for all operators. Understanding this order of operations is critical for evaluating any expression in python.