##// END OF EJS Templates
Remove old mentions and uses of ipython_extension_dir...
Remove old mentions and uses of ipython_extension_dir The bulk of this functionality was removed in IPython 8.6.0, but there were still mentions of it in the docs and in the reload code.

File last commit:

r20547:8f4e2b41
r28597:3f2bb728
Show More
Raw Input in the Notebook.ipynb
151 lines | 5.9 KiB | text/plain | TextLexer
/ examples / IPython Kernel / Raw Input in the Notebook.ipynb
Brian E. Granger
Splitting notebooks.
r16088 {
Min RK
upate exmaple notebooks to nbformat v4
r18669 "cells": [
Brian E. Granger
Splitting notebooks.
r16088 {
Min RK
upate exmaple notebooks to nbformat v4
r18669 "cell_type": "markdown",
"metadata": {},
"source": [
"# Using `raw_input` and `%debug` in the Notebook"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The Notebook has added support for `raw_input` and `%debug`, as of 1.0."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Python 3 compat\n",
"import sys\n",
"if sys.version_info[0] >= 3:\n",
" raw_input = input"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
Brian E. Granger
Splitting notebooks.
r16088 {
Min RK
upate exmaple notebooks to nbformat v4
r18669 "name": "stdout",
"output_type": "stream",
"text": [
"What is your name? Sir Robin\n"
Brian E. Granger
Splitting notebooks.
r16088 ]
},
{
Min RK
upate exmaple notebooks to nbformat v4
r18669 "data": {
"text/plain": [
"'Sir Robin'"
]
},
"execution_count": 2,
Brian E. Granger
Splitting notebooks.
r16088 "metadata": {},
Min RK
upate exmaple notebooks to nbformat v4
r18669 "output_type": "execute_result"
}
],
"source": [
"name = raw_input(\"What is your name? \")\n",
"name"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
Brian E. Granger
Splitting notebooks.
r16088 {
Min RK
upate exmaple notebooks to nbformat v4
r18669 "ename": "ZeroDivisionError",
Min RK
pass on IPython Kernel example notebooks...
r20547 "evalue": "division by zero",
Min RK
upate exmaple notebooks to nbformat v4
r18669 "output_type": "error",
"traceback": [
Min RK
pass on IPython Kernel example notebooks...
r20547 "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mZeroDivisionError\u001b[0m Traceback (most recent call last)",
Min RK
upate exmaple notebooks to nbformat v4
r18669 "\u001b[1;32m<ipython-input-4-a5097cc0c0c5>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m/\u001b[0m\u001b[0my\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m \u001b[0mdiv\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;32m<ipython-input-4-a5097cc0c0c5>\u001b[0m in \u001b[0;36mdiv\u001b[1;34m(x, y)\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mdiv\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m/\u001b[0m\u001b[0my\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 3\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[0mdiv\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
Min RK
pass on IPython Kernel example notebooks...
r20547 "\u001b[1;31mZeroDivisionError\u001b[0m: division by zero"
Min RK
upate exmaple notebooks to nbformat v4
r18669 ]
}
],
"source": [
"def div(x, y):\n",
" return x/y\n",
"\n",
"div(1,0)"
]
},
{
"cell_type": "code",
Min RK
pass on IPython Kernel example notebooks...
r20547 "execution_count": 4,
Min RK
upate exmaple notebooks to nbformat v4
r18669 "metadata": {
"collapsed": false
},
"outputs": [
Brian E. Granger
Splitting notebooks.
r16088 {
Min RK
upate exmaple notebooks to nbformat v4
r18669 "name": "stdout",
"output_type": "stream",
"text": [
"> \u001b[1;32m<ipython-input-4-a5097cc0c0c5>\u001b[0m(2)\u001b[0;36mdiv\u001b[1;34m()\u001b[0m\n",
"\u001b[1;32m 1 \u001b[1;33m\u001b[1;32mdef\u001b[0m \u001b[0mdiv\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[0m\u001b[1;32m----> 2 \u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m/\u001b[0m\u001b[0my\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[0m\u001b[1;32m 3 \u001b[1;33m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[0m\n",
"ipdb> x\n",
"1\n",
"ipdb> y\n",
"0\n",
Min RK
pass on IPython Kernel example notebooks...
r20547 "ipdb> bt\n",
" \u001b[1;32m<ipython-input-4-a5097cc0c0c5>\u001b[0m(4)\u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n",
"\u001b[0;32m 1 \u001b[0m\u001b[1;32mdef\u001b[0m \u001b[0mdiv\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[0;32m 2 \u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m/\u001b[0m\u001b[0my\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[0;32m 3 \u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32m----> 4 \u001b[1;33m\u001b[0mdiv\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[0m\n",
"> \u001b[1;32m<ipython-input-4-a5097cc0c0c5>\u001b[0m(2)\u001b[0;36mdiv\u001b[1;34m()\u001b[0m\n",
"\u001b[1;32m 1 \u001b[1;33m\u001b[1;32mdef\u001b[0m \u001b[0mdiv\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[0m\u001b[1;32m----> 2 \u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m/\u001b[0m\u001b[0my\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[0m\u001b[1;32m 3 \u001b[1;33m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[0m\u001b[1;32m 4 \u001b[1;33m\u001b[0mdiv\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[0m\n",
Min RK
upate exmaple notebooks to nbformat v4
r18669 "ipdb> exit\n"
]
Brian E. Granger
Splitting notebooks.
r16088 }
],
Min RK
upate exmaple notebooks to nbformat v4
r18669 "source": [
"%debug"
]
Brian E. Granger
Splitting notebooks.
r16088 }
Min RK
upate exmaple notebooks to nbformat v4
r18669 ],
Min RK
add kernel metadata to example notebooks
r20278 "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.2"
}
},
Min RK
upate exmaple notebooks to nbformat v4
r18669 "nbformat": 4,
"nbformat_minor": 0
Min RK
add kernel metadata to example notebooks
r20278 }