Skip to content

Instantly share code, notes, and snippets.

@mythmon
Created October 17, 2015 00:02
Show Gist options
  • Save mythmon/a027f93ecf43f8f06437 to your computer and use it in GitHub Desktop.
Save mythmon/a027f93ecf43f8f06437 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {
"trusted": true,
"collapsed": false
},
"cell_type": "code",
"source": "from collections import defaultdict\n\ndef vivify():\n return defaultdict(vivify)\n\nd = vivify()\n\nd['foo']['bar']['qux']['wat'] = 'baz'\n\nd",
"execution_count": 12,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": "defaultdict(<function __main__.vivify>,\n {'foo': defaultdict(<function __main__.vivify>,\n {'bar': defaultdict(<function __main__.vivify>,\n {'qux': defaultdict(<function __main__.vivify>,\n {'wat': 'baz'})})})})"
},
"metadata": {},
"execution_count": 12
}
]
},
{
"metadata": {
"trusted": true,
"collapsed": true
},
"cell_type": "code",
"source": "",
"execution_count": null,
"outputs": []
}
],
"metadata": {
"kernelspec": {
"name": "python3",
"display_name": "Python 3",
"language": "python"
},
"language_info": {
"codemirror_mode": {
"version": 3,
"name": "ipython"
},
"nbconvert_exporter": "python",
"name": "python",
"file_extension": ".py",
"version": "3.5.0",
"mimetype": "text/x-python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment