Hacker News new | ask | show | jobs
by collyw 2244 days ago
Would I be correct in avoiding "is" for any simple data types, and only using it for objects?
3 comments

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.

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`.

See the comment by lonelappde, but note that the example under discussion here is actually not about `is` vs. `==` either.