In Python3,
a = b = 3
a is None == b is None
returns False, but
(a is None) == (b is None)
returns True. So I would assume based on this example alone, == has precedence over is.
However,
a = b = None
a is None == b is None
returns True. And
(a is None) == (b is None)
returns True. But
a is (None == b) is None
returns False. In this case, it would seem as if is has precedence over ==.
To give another example, and this expression isn't meant to do anything, but bear with me please. If I say
None is None == None
it returns True. But both of the following return False.
None is (None == None)
(None is None) == None
So clearly, Python isn't evaluating these with some strict precedence, but I'm confused what is going on. How is it evaluating this expression with 2 different operators, but differently from either order?