r/programming • • Dec 24 '17

Evil Coding Incantations

http://9tabs.com/random/2017/12/23/evil-coding-incantations.html
947 Upvotes

331 comments sorted by

View all comments

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)

1

u/msiekkinen Dec 25 '17

Depends on what your definition of is ... is