Skip to content

Instantly share code, notes, and snippets.

@gbishop
Created February 5, 2016 18:17
Show Gist options
  • Save gbishop/6d20f3d6f0f4c84db0c7 to your computer and use it in GitHub Desktop.
Save gbishop/6d20f3d6f0f4c84db0c7 to your computer and use it in GitHub Desktop.
Get sys.argv from the query string. This way I can link notebooks together passing args along.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"application/javascript": [
"var query = IPython.notebook.notebook_name + '&' + window.location.search.substring(1);\n",
"IPython.notebook.kernel.execute(\"import sys; sys.argv = '\" + query + \"'.split('&')\")"
],
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%javascript\n",
"var query = IPython.notebook.notebook_name + '&' + window.location.search.substring(1);\n",
"IPython.notebook.kernel.execute(\"import sys; sys.argv = '\" + query + \"'.split('&')\")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"['Grade.ipynb', 'assignment=A2']"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import sys\n",
"sys.argv"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"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.4.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment