Chained expressions are evaluated from left to right, besides, comparisons is
and !=
have the same precedence, so that your expression is evaluated as:
(x is None) and (None!= y) and (y is None)
#---True----|------True-----|--- False---|
#-----------True------------|
#------------------False-----------------|
To change the order of evaluation, you should put some parens:
>>> (x is None) != (y is None)
True
Also note that the first expression x is None == y is None
was a fluke, or rather the red herring, as you'll get the same results if you place some parens in the required positions. It's probably why you assumed the order should start with the is
first, then the !=
in the second case.