Reputation: 189
If None and None
returns None
, (None and None is None)
should return True
, No?
Was debugging an app and noticed that it returns None
Upvotes: 0
Views: 52
Reputation: 3363
Good question!
(None and None is None)
"is" has a priority, so None is None
returns True
"and" executed after that, so None and True
result in None
If you add parenthesis, you can make it work in another way:
((None and None) is None)
returns True
You can find more info on that topic here: https://docs.python.org/3/reference/expressions.html#operator-precedence
Upvotes: 3