Skip to content

Instantly share code, notes, and snippets.

@zaccharieramzi
Created February 25, 2022 12:02
Show Gist options
  • Save zaccharieramzi/40b0d2686c7961593e013374d0e19a4d to your computer and use it in GitHub Desktop.
Save zaccharieramzi/40b0d2686c7961593e013374d0e19a4d to your computer and use it in GitHub Desktop.
why_not_good_list_defaults.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "why_not_good_list_defaults.ipynb",
"provenance": [],
"authorship_tag": "ABX9TyNLRi1mYW5kM/86fcRzGNU+",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/zaccharieramzi/40b0d2686c7961593e013374d0e19a4d/why_not_good_list_defaults.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "qZVFGqWCwZjf",
"outputId": "d307a727-fb34-43db-a505-ff14bafdb026"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"[1, 2, 3]\n",
"[1, 2, 3, 3]\n"
]
}
],
"source": [
"def my_function_w_list_default(l=[1,2]):\n",
" l.append(3)\n",
" print(l)\n",
"\n",
"\n",
"my_function_w_list_default()\n",
"my_function_w_list_default()"
]
},
{
"cell_type": "code",
"source": [
""
],
"metadata": {
"id": "4a0rWzAewno_"
},
"execution_count": null,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment