4 ms·
Would I be correct in avoiding "is" for any simple data types, and only using it for objects?
by collyw 7y ago
Would I be correct in avoiding "is" for any simple data types, and only using it for objects?
- lonelappde 7y agoIntegers are not simple data types in python. https://docs.python.org/2/c-api/int.html#PyInt_FromLong 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.
- sbergjohansen 7y agoSee the comment by lonelappde, but note that the example under discussion here is actually not about `is` vs. `==` either.
- Scarblac 7y agoIt'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`.