Parsing in Python between 'in', '==' and 'is'

27 views Asked by At

I would like to understand how parsing in Python works. More specifically, how can these three statements give three different results :

0 in [0] is True 
# returns False
(0 in [0]) is True 
# returns True
0 in ([0] is True)
# raises TypeError

while only two different results are obtained with

1 == 1 is True 
# returns False
(1 == 1) is True 
# returns True
1 == (1 is True)
# returns False
0

There are 0 answers