Answer the question
In order to leave comments, you need to log in
What is the priority of operations in this situation with None, is and !=?
Why and how does operator precedence work?
>>> (1 != (None is None))
False
>>> (1 != None) is None
False
>>> (1 != None is None)
True
Answer the question
In order to leave comments, you need to log in
(1 != (None is None))
Before comparing 1 and the second expression, python evaluates the expression. i.e .:
1. (None is None) = True
2. 1 != True
https://docs.python.org/release/3.0.1/reference/da...
The Boolean type is a subtype of the integer type, and Boolean values behave like the values 0 and 1, respectively, in almost all contexts, the exception being that when converted to a string, the strings "False" or "True" are returned , respectively.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question