##// END OF EJS Templates
fix a couple of invalid notebooks...
MinRK -
Show More
@@ -1,196 +1,191 b''
1 1 {
2 2 "metadata": {
3 3 "name": "",
4 4 "signature": "sha256:ac5c21534f3dd013c78d4d201527f3ed4dea5b6fad4116b8d23c67ba107e48c3"
5 5 },
6 6 "nbformat": 3,
7 7 "nbformat_minor": 0,
8 8 "worksheets": [
9 9 {
10 10 "cells": [
11 11 {
12 12 "cell_type": "heading",
13 13 "level": 1,
14 14 "metadata": {},
15 15 "source": [
16 16 "Using `raw_input` and `%debug` in the Notebook"
17 17 ]
18 18 },
19 19 {
20 20 "cell_type": "markdown",
21 21 "metadata": {},
22 22 "source": [
23 23 "The Notebook has added support for `raw_input` and `%debug`, as of 1.0."
24 24 ]
25 25 },
26 26 {
27 27 "cell_type": "code",
28 28 "collapsed": false,
29 29 "input": [
30 30 "# Python 3 compat\n",
31 31 "import sys\n",
32 32 "if sys.version_info[0] >= 3:\n",
33 33 " raw_input = input"
34 34 ],
35 35 "language": "python",
36 36 "metadata": {},
37 37 "outputs": [],
38 38 "prompt_number": 1
39 39 },
40 40 {
41 41 "cell_type": "code",
42 42 "collapsed": false,
43 43 "input": [
44 44 "name = raw_input(\"What is your name? \")\n",
45 45 "name"
46 46 ],
47 47 "language": "python",
48 48 "metadata": {},
49 49 "outputs": [
50 50 {
51 "name": "stdout",
52 51 "output_type": "stream",
53 52 "stream": "stdout",
54 53 "text": [
55 54 "What is your name? Sir Robin\n"
56 55 ]
57 56 },
58 57 {
59 58 "metadata": {},
60 59 "output_type": "pyout",
61 60 "prompt_number": 2,
62 61 "text": [
63 62 "'Sir Robin'"
64 63 ]
65 64 }
66 65 ],
67 66 "prompt_number": 2
68 67 },
69 68 {
70 69 "cell_type": "markdown",
71 70 "metadata": {},
72 71 "source": [
73 72 "**Python 2-only**: the eval input works as well (`input` is just `eval(raw_input(prompt))`)"
74 73 ]
75 74 },
76 75 {
77 76 "cell_type": "code",
78 77 "collapsed": false,
79 78 "input": [
80 79 "fingers = input(\"How many fingers? \")\n",
81 80 "fingers, type(fingers)"
82 81 ],
83 82 "language": "python",
84 83 "metadata": {},
85 84 "outputs": [
86 85 {
87 "name": "stdout",
88 86 "output_type": "stream",
89 87 "stream": "stdout",
90 88 "text": [
91 89 "How many fingers? 4\n"
92 90 ]
93 91 },
94 92 {
95 93 "metadata": {},
96 94 "output_type": "pyout",
97 95 "prompt_number": 3,
98 96 "text": [
99 97 "(4, int)"
100 98 ]
101 99 }
102 100 ],
103 101 "prompt_number": 3
104 102 },
105 103 {
106 104 "cell_type": "code",
107 105 "collapsed": false,
108 106 "input": [
109 107 "def div(x, y):\n",
110 108 " return x/y\n",
111 109 "\n",
112 110 "div(1,0)"
113 111 ],
114 112 "language": "python",
115 113 "metadata": {},
116 114 "outputs": [
117 115 {
118 116 "ename": "ZeroDivisionError",
119 117 "evalue": "integer division or modulo by zero",
120 118 "output_type": "pyerr",
121 119 "traceback": [
122 120 "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mZeroDivisionError\u001b[0m Traceback (most recent call last)",
123 121 "\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",
124 122 "\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",
125 123 "\u001b[1;31mZeroDivisionError\u001b[0m: integer division or modulo by zero"
126 124 ]
127 125 }
128 126 ],
129 127 "prompt_number": 4
130 128 },
131 129 {
132 130 "cell_type": "code",
133 131 "collapsed": false,
134 132 "input": [
135 133 "%debug"
136 134 ],
137 135 "language": "python",
138 136 "metadata": {},
139 137 "outputs": [
140 138 {
141 139 "output_type": "stream",
142 140 "stream": "stdout",
143 141 "text": [
144 142 "> \u001b[1;32m<ipython-input-4-a5097cc0c0c5>\u001b[0m(2)\u001b[0;36mdiv\u001b[1;34m()\u001b[0m\n",
145 143 "\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",
146 144 "\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",
147 145 "\u001b[0m\u001b[1;32m 3 \u001b[1;33m\u001b[1;33m\u001b[0m\u001b[0m\n",
148 146 "\u001b[0m\n"
149 147 ]
150 148 },
151 149 {
152 "name": "stdout",
153 150 "output_type": "stream",
154 151 "stream": "stdout",
155 152 "text": [
156 153 "ipdb> x\n"
157 154 ]
158 155 },
159 156 {
160 157 "output_type": "stream",
161 158 "stream": "stdout",
162 159 "text": [
163 160 "1\n"
164 161 ]
165 162 },
166 163 {
167 "name": "stdout",
168 164 "output_type": "stream",
169 165 "stream": "stdout",
170 166 "text": [
171 167 "ipdb> y\n"
172 168 ]
173 169 },
174 170 {
175 171 "output_type": "stream",
176 172 "stream": "stdout",
177 173 "text": [
178 174 "0\n"
179 175 ]
180 176 },
181 177 {
182 "name": "stdout",
183 178 "output_type": "stream",
184 179 "stream": "stdout",
185 180 "text": [
186 181 "ipdb> exit\n"
187 182 ]
188 183 }
189 184 ],
190 185 "prompt_number": 5
191 186 }
192 187 ],
193 188 "metadata": {}
194 189 }
195 190 ]
196 191 } No newline at end of file
@@ -1,61 +1,61 b''
1 1 {
2 2 "metadata": {
3 3 "name": "gilsleep"
4 4 },
5 5 "nbformat": 3,
6 6 "nbformat_minor": 0,
7 7 "worksheets": [
8 8 {
9 9 "cells": [
10 10 {
11 11 "cell_type": "markdown",
12 12 "metadata": {},
13 13 "source": [
14 14 "Holding the GIL for too long could disrupt the heartbeat due to non-copying sends.\n",
15 15 "\n",
16 16 "The following cell repeatedly calls a function that holds the GIL for five seconds.\n",
17 17 "\n",
18 18 "The heartbeat will fail after a few iterations prior to fixing Issue [#1260](https://github.com/ipython/ipython/issues/1260)."
19 19 ]
20 20 },
21 21 {
22 22 "cell_type": "code",
23 23 "collapsed": false,
24 24 "input": [
25 25 "import sys\n",
26 26 "import time\n",
27 27 "\n",
28 28 "from cython import inline\n",
29 29 "\n",
30 30 "def gilsleep(t):\n",
31 31 " \"\"\"gil-holding sleep with cython.inline\"\"\"\n",
32 32 " code = '\\n'.join([\n",
33 33 " 'from posix cimport unistd',\n",
34 34 " 'unistd.sleep(t)',\n",
35 35 " ])\n",
36 36 " while True:\n",
37 37 " inline(code, quiet=True, t=t)\n",
38 38 " print time.time()\n",
39 39 " sys.stdout.flush() # this is important\n",
40 40 "\n",
41 41 "gilsleep(5)"
42 42 ],
43 43 "language": "python",
44 44 "metadata": {},
45 45 "outputs": [],
46 46 "prompt_number": 1
47 47 },
48 48 {
49 49 "cell_type": "code",
50 50 "collapsed": true,
51 51 "input": [],
52 52 "language": "python",
53 53 "metadata": {},
54 54 "outputs": [],
55 "prompt_number": "&nbsp;"
55 "prompt_number": null
56 56 }
57 57 ],
58 58 "metadata": {}
59 59 }
60 60 ]
61 61 } No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now