aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/resources/tags/identity.md25
1 files changed, 25 insertions, 0 deletions
diff --git a/bot/resources/tags/identity.md b/bot/resources/tags/identity.md
new file mode 100644
index 000000000..32995aef6
--- /dev/null
+++ b/bot/resources/tags/identity.md
@@ -0,0 +1,25 @@
+**Identity vs. Equality**
+
+Should I be using `is` or `==`?
+
+To check if two things are equal, use the equality operator (`==`).
+```py
+x = 5
+if x == 5:
+ print("x equals 5")
+if x == 3:
+ print("x equals 3")
+# Prints 'x equals 5'
+```
+
+To check if two things are actually the same thing in memory, use the identity comparison operator (`is`).
+```py
+x = [1, 2, 3]
+y = [1, 2, 3]
+if x is [1, 2, 3]:
+ print("x is y")
+z = x
+if x is z:
+ print("x is z")
+# Prints 'x is z'
+```