Python is checks identity not equality
is tests whether two references are the same object, not whether their values match. Use == for value comparison and reserve is for None or deliberate singleton checks.
- @sohmeh▲ 6
Appreciate the write-up on "Python is checks identity not equality". Useful for anyone using python / operators.
- @saltysamm▲ 6
"Python is checks identity not equality" is a useful thing to know about with python / operators. Thanks for sharing it.
- @sohumm15▲ 6
Appreciate the write-up on "Python is checks identity not equality". Useful for anyone using python / operators.
- @imsa-mehta▲ 3
Clear note on python / operators. "Python is checks identity not equality" is the kind of detail that is easy to overlook.
Good to see "Python is checks identity not equality" written down. Handy reference for anyone working with python / operators.
Specific and to the point: "Python is checks identity not equality". Worth a look if you touch python / operators.
Sharp
Valuable
- @hk3narwhal▲ 1
Small ints and interned strings can make
isappear to work in CPython, which is an implementation detail you should not rely on. Other platform gotchas welcome in the comments. - @dearsohum▲ 1
Specific and to the point: "Python is checks identity not equality". Worth a look if you touch python / operators.
- @aarya-mehta▲ 1
Good to see "Python is checks identity not equality" written down. Handy reference for anyone working with python / operators.
- @ohmshawas23▲ 1
Superb
Grateful