News for hackers. Stuff that matters.
Re:Why does `True == False is False` evaluate to False in Py... by sbergjohansen on Saturday May 02, 2020 @04:41AM (#23050360)
To see that this is not about precedence, evaluate the following:

  >>> True == False is False
  False
  >>> False == True is False
  False
Re:Why does `True == False is False` evaluate to False in Py... by cjhopman on Saturday May 02, 2020 @07:26AM (#23051092)
Or think about it for a moment and realize that it would be True with either precedence if interpreted as expected.

Or read the very first part of the linked page that shows:

  >>> (True == False) is False
  True
  >>> True == (False is False)
  True
Re:Why does `True == False is False` evaluate to False in Py... by collyw on Saturday May 02, 2020 @09:06AM (#23051542)
Would I be correct in avoiding "is" for any simple data types, and only using it for objects?
Re:Why does `True == False is False` evaluate to False in Py... by lonelappde on Saturday May 02, 2020 @09:27AM (#23051654)
Integers are not simple data types in python. https://docs.python.org/2/c-api/int.html#PyInt_FromLong

You'd be correct to use 'is' to mean 'is', and '==' to mean '==', following their definitions.

Re:Why does `True == False is False` evaluate to False in Py... by Scarblac on Saturday May 02, 2020 @10:28AM (#23051976)
It's idiomatic to use it for comparisons with the value `None`, which is a singleton so it's always that one.

Other than that, just don't use `is`.

Re:Why does `True == False is False` evaluate to False in Py... by sbergjohansen on Saturday May 02, 2020 @09:43AM (#23051733)
See the comment by lonelappde, but note that the example under discussion here is actually not about `is` vs. `==` either.
Re:Why does `True == False is False` evaluate to False in Py... by sbergjohansen on Saturday May 02, 2020 @08:23AM (#23051329)
Yes. By the time I realised my second example is redundant, it was already too late to edit the comment. Thanks for clarifying.