Add text that elaborates on 'is' with '=' (#21537)
I added text that explicitly states the 'is' is signified with '=' since that was not already written and can help beginners distinguish better.
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
title: Difference between Python 'is' and '==' operators
|
title: Difference between Python 'is' and '==' operators
|
||||||
---
|
---
|
||||||
`is` is a check for object identity - ie, checking if two or more variables are referring to the same object. You can't overload `is`.
|
`is` is a check for object identity - ie, checking if two or more variables are referring to the same object. You can't overload `is`. That object identity is established and assigned with `=`.
|
||||||
|
|
||||||
`==` evaluates to true if object referred to by the variables are equal. You can overload `==` via the `__eq__` operator.
|
`==` evaluates to true if object referred to by the variables are equal. You can overload `==` via the `__eq__` operator.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user