diff --git a/.ipynb_checkpoints/not_so_obvious_python_stuff-checkpoint.ipynb b/.ipynb_checkpoints/not_so_obvious_python_stuff-checkpoint.ipynb
index 514778f..48d834c 100644
--- a/.ipynb_checkpoints/not_so_obvious_python_stuff-checkpoint.ipynb
+++ b/.ipynb_checkpoints/not_so_obvious_python_stuff-checkpoint.ipynb
@@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
- "signature": "sha256:6bc56360203df31596f6332e4b5c73effb2572d18b60bdf6a792042e2fde8c12"
+ "signature": "sha256:0c860c383edcd7622b0c660eb989513e90496c7350916bae1ddb6c10f29fab2c"
},
"nbformat": 3,
"nbformat_minor": 0,
@@ -40,9 +40,10 @@
"- [The C3 class resolution algorithm for multiple class inheritance](#c3_class_res)\n",
"- [The behavior of += for lists](#pm_in_lists)\n",
"- [`True` and `False` in the datetime module](#datetime_module)\n",
- "- [Python reuses objects for small integers](#python_small_int)\n",
+ "- [Python reuses objects for small integers - always use \"==\" for equality, \"is\" for identity](#python_small_int)\n",
"- [Shallow vs. deep copies if list contains other structures and objects](#shallow_vs_deep)\n",
- "- [Picking True values from and and or expressions](#false_true_expressions)"
+ "- [Picking True values from and and or expressions](#false_true_expressions)\n",
+ "- [Don't use mutable objects as default arguments for functions!](#def_mutable_func)"
]
},
{
@@ -189,10 +190,12 @@
"
\n",
"
\n",
"\n",
- "## Python reuses objects for small integers \n",
+ "## Python reuses objects for small integers - always use \"==\" for equality, \"is\" for identity\n",
"\n",
"This oddity occurs, because Python tends to stores small integers as the same object, but not so for larger ones! \n",
- "(*I received a comment that this is in fact a CPython artefact and must not necessarily be true in all implementations of Python!*)"
+ "(*I received a comment that this is in fact a CPython artefact and must not necessarily be true in all implementations of Python!*)\n",
+ "\n",
+ "So the take home message is: always use \"==\" for equality, \"is\" for identity!"
]
},
{
@@ -335,7 +338,7 @@
"source": [
"
\n",
"
\n",
- "\n",
"## Don't use mutable objects as default arguments for functions!"
]
},
diff --git a/not_so_obvious_python_stuff.ipynb b/not_so_obvious_python_stuff.ipynb
index 7dc2ad4..48d834c 100644
--- a/not_so_obvious_python_stuff.ipynb
+++ b/not_so_obvious_python_stuff.ipynb
@@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
- "signature": "sha256:158ad35cd56abe8905983dc63421b3b7b54d28a947df54f67a3b7f0a53e31481"
+ "signature": "sha256:0c860c383edcd7622b0c660eb989513e90496c7350916bae1ddb6c10f29fab2c"
},
"nbformat": 3,
"nbformat_minor": 0,
@@ -40,7 +40,7 @@
"- [The C3 class resolution algorithm for multiple class inheritance](#c3_class_res)\n",
"- [The behavior of += for lists](#pm_in_lists)\n",
"- [`True` and `False` in the datetime module](#datetime_module)\n",
- "- [Python reuses objects for small integers](#python_small_int)\n",
+ "- [Python reuses objects for small integers - always use \"==\" for equality, \"is\" for identity](#python_small_int)\n",
"- [Shallow vs. deep copies if list contains other structures and objects](#shallow_vs_deep)\n",
"- [Picking True values from and and or expressions](#false_true_expressions)\n",
"- [Don't use mutable objects as default arguments for functions!](#def_mutable_func)"
@@ -190,10 +190,12 @@
"
\n",
"
\n",
"\n",
- "## Python reuses objects for small integers \n",
+ "## Python reuses objects for small integers - always use \"==\" for equality, \"is\" for identity\n",
"\n",
"This oddity occurs, because Python tends to stores small integers as the same object, but not so for larger ones! \n",
- "(*I received a comment that this is in fact a CPython artefact and must not necessarily be true in all implementations of Python!*)"
+ "(*I received a comment that this is in fact a CPython artefact and must not necessarily be true in all implementations of Python!*)\n",
+ "\n",
+ "So the take home message is: always use \"==\" for equality, \"is\" for identity!"
]
},
{