Skip to content

Instantly share code, notes, and snippets.

@kanazux
Created March 28, 2018 09:42
Show Gist options
  • Save kanazux/52904d79850f38a0ea191842bfab09bd to your computer and use it in GitHub Desktop.
Save kanazux/52904d79850f38a0ea191842bfab09bd to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"140505226920328\n"
]
}
],
"source": [
"print(id([]))\n",
"def foo(bar = []):\n",
" print(id(bar))\n",
" bar.append('a')\n",
" print(bar)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"140505226057608\n",
"['a']\n",
"140505226057608\n",
"['a', 'a']\n",
"140505226057608\n",
"['a', 'a', 'a']\n"
]
}
],
"source": [
"foo()\n",
"foo()\n",
"foo()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment