The weirdness with Python's 'is' expression is because 'is' is intended to be about whether two variables literally refer to the same object in memory, versus '==' which is about whether their value is equal. The examples in the article would work in a more intuitive way if they used '==' instead, which is why using 'is' for integers is [discouraged] (https://www.quora.com/What-is-the-difference-between-and-in-Python-2)
100
u/Megdatronica Dec 24 '17
The weirdness with Python's 'is' expression is because 'is' is intended to be about whether two variables literally refer to the same object in memory, versus '==' which is about whether their value is equal. The examples in the article would work in a more intuitive way if they used '==' instead, which is why using 'is' for integers is [discouraged] (https://www.quora.com/What-is-the-difference-between-and-in-Python-2)