Show More
@@ -181,11 +181,11 b' magic, a cell one and one that works in both modes, using just plain functions:' | |||
|
181 | 181 | |
|
182 | 182 | from IPython.core.magic import (register_line_magic, register_cell_magic, |
|
183 | 183 | register_line_cell_magic) |
|
184 | ||
|
184 | ||
|
185 | 185 | @register_line_magic |
|
186 | 186 | def lmagic(line): |
|
187 | 187 | "my line magic" |
|
188 |
|
|
|
188 | return line | |
|
189 | 189 | |
|
190 | 190 | @register_cell_magic |
|
191 | 191 | def cmagic(line, cell): |
@@ -195,11 +195,11 b' magic, a cell one and one that works in both modes, using just plain functions:' | |||
|
195 | 195 | @register_line_cell_magic |
|
196 | 196 | def lcmagic(line, cell=None): |
|
197 | 197 | "Magic that works both as %lcmagic and as %%lcmagic" |
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
|
201 | else: | |
|
202 |
|
|
|
198 | if cell is None: | |
|
199 | print("Called as line magic") | |
|
200 | return line | |
|
201 | else: | |
|
202 | print("Called as cell magic") | |
|
203 | 203 | return line, cell |
|
204 | 204 | |
|
205 | 205 | # We delete these to avoid name conflicts for automagic to work |
@@ -212,10 +212,11 b' potentially hold state in between calls, and that have full access to the main' | |||
|
212 | 212 | IPython object: |
|
213 | 213 | |
|
214 | 214 | .. sourcecode:: python |
|
215 | ||
|
215 | ||
|
216 | 216 | # This code can be put in any Python module, it does not require IPython |
|
217 | 217 | # itself to be running already. It only creates the magics subclass but |
|
218 | 218 | # doesn't instantiate it yet. |
|
219 | from __future__ import print_function | |
|
219 | 220 | from IPython.core.magic import (Magics, magics_class, line_magic, |
|
220 | 221 | cell_magic, line_cell_magic) |
|
221 | 222 | |
@@ -226,8 +227,8 b' IPython object:' | |||
|
226 | 227 | @line_magic |
|
227 | 228 | def lmagic(self, line): |
|
228 | 229 | "my line magic" |
|
229 |
print |
|
|
230 |
print |
|
|
230 | print("Full access to the main IPython object:", self.shell) | |
|
231 | print("Variables in the user namespace:", list(self.shell.user_ns.keys())) | |
|
231 | 232 | return line |
|
232 | 233 | |
|
233 | 234 | @cell_magic |
@@ -239,10 +240,10 b' IPython object:' | |||
|
239 | 240 | def lcmagic(self, line, cell=None): |
|
240 | 241 | "Magic that works both as %lcmagic and as %%lcmagic" |
|
241 | 242 | if cell is None: |
|
242 |
print |
|
|
243 | print("Called as line magic") | |
|
243 | 244 | return line |
|
244 | 245 | else: |
|
245 |
print |
|
|
246 | print("Called as cell magic") | |
|
246 | 247 | return line, cell |
|
247 | 248 | |
|
248 | 249 | |
@@ -259,11 +260,11 b' additional state, then you should always call the parent constructor and' | |||
|
259 | 260 | instantiate the class yourself before registration: |
|
260 | 261 | |
|
261 | 262 | .. sourcecode:: python |
|
262 | ||
|
263 | ||
|
263 | 264 | @magics_class |
|
264 | 265 | class StatefulMagics(Magics): |
|
265 | 266 | "Magics that hold additional state" |
|
266 | ||
|
267 | ||
|
267 | 268 | def __init__(self, shell, data): |
|
268 | 269 | # You must call the parent constructor |
|
269 | 270 | super(StatefulMagics, self).__init__(shell) |
@@ -288,8 +289,8 b' follows:' | |||
|
288 | 289 | .. sourcecode:: python |
|
289 | 290 | |
|
290 | 291 | def func(self, line): |
|
291 |
print |
|
|
292 |
|
|
|
292 | print("Line magic called with line:", line) | |
|
293 | print("IPython object:", self.shell) | |
|
293 | 294 | |
|
294 | 295 | ip = get_ipython() |
|
295 | 296 | # Declare this function as the magic %mycommand |
@@ -961,7 +962,7 b' standard Python tutorial::' | |||
|
961 | 962 | In [3]: ... a, b = 0, 1 |
|
962 | 963 | |
|
963 | 964 | In [4]: >>> while b < 10: |
|
964 |
...: ... print |
|
|
965 | ...: ... print(b) | |
|
965 | 966 | ...: ... a, b = b, a+b |
|
966 | 967 | ...: |
|
967 | 968 | 1 |
@@ -62,7 +62,7 b' mechanism, this is automatically stored::' | |||
|
62 | 62 | |
|
63 | 63 | hello - this is a temporary file |
|
64 | 64 | |
|
65 |
Out[1]: "print |
|
|
65 | Out[1]: "print('hello - this is a temporary file')\n" | |
|
66 | 66 | |
|
67 | 67 | Now, if you call ``%edit -p``, IPython tries to open an editor with the |
|
68 | 68 | same data as the last time you used %edit. So if you haven't used %edit |
@@ -82,7 +82,7 b' Continuing with the example above, this should illustrate this idea::' | |||
|
82 | 82 | |
|
83 | 83 | hello - now I made some changes |
|
84 | 84 | |
|
85 |
Out[2]: "print |
|
|
85 | Out[2]: "print('hello - now I made some changes')\n" | |
|
86 | 86 | |
|
87 | 87 | In [3]: edit _1 |
|
88 | 88 | |
@@ -94,7 +94,7 b' Continuing with the example above, this should illustrate this idea::' | |||
|
94 | 94 | |
|
95 | 95 | IPython version control at work :) |
|
96 | 96 | |
|
97 |
Out[3]: "print |
|
|
97 | Out[3]: "print('hello - this is a temporary file')\nprint('IPython version control at work :)')\n" | |
|
98 | 98 | |
|
99 | 99 | |
|
100 | 100 | This section was written after a contribution by Alexander Belchenko on |
@@ -30,8 +30,6 b' When the config attribute of an Application is updated, it will fire all of' | |||
|
30 | 30 | the trait's events for all of the config=True attributes. |
|
31 | 31 | """ |
|
32 | 32 | |
|
33 | import sys | |
|
34 | ||
|
35 | 33 | from IPython.config.configurable import Configurable |
|
36 | 34 | from IPython.config.application import Application |
|
37 | 35 | from IPython.utils.traitlets import ( |
@@ -87,8 +85,8 b' class MyApp(Application):' | |||
|
87 | 85 | self.init_bar() |
|
88 | 86 | |
|
89 | 87 | def start(self): |
|
90 |
print |
|
|
91 |
print |
|
|
88 | print("app.config:") | |
|
89 | print(self.config) | |
|
92 | 90 | |
|
93 | 91 | |
|
94 | 92 | def main(): |
@@ -17,7 +17,6 b' to build much more flexible and powerful tools to browse and pull from the' | |||
|
17 | 17 | history database. |
|
18 | 18 | """ |
|
19 | 19 | import sys |
|
20 | import codecs | |
|
21 | 20 | |
|
22 | 21 | from IPython.core.history import HistoryAccessor |
|
23 | 22 | |
@@ -34,5 +33,5 b' dest.write("# coding: utf-8\\n")' | |||
|
34 | 33 | hist = HistoryAccessor() |
|
35 | 34 | |
|
36 | 35 | for session, lineno, cell in hist.get_range(session=session_number, raw=raw): |
|
37 | # To use this in Python 3, remove the .encode() here: | |
|
38 |
dest.write(cell |
|
|
36 | cell = cell.encode('utf-8') # This line is only needed on Python 2. | |
|
37 | dest.write(cell + '\n') |
@@ -1,3 +1,4 b'' | |||
|
1 | from __future__ import print_function | |
|
1 | 2 | import os |
|
2 | 3 | |
|
3 | 4 | from IPython.qt.console.rich_ipython_widget import RichIPythonWidget |
@@ -6,7 +7,7 b' from IPython.lib import guisupport' | |||
|
6 | 7 | |
|
7 | 8 | |
|
8 | 9 | def print_process_id(): |
|
9 |
print |
|
|
10 | print('Process ID is:', os.getpid()) | |
|
10 | 11 | |
|
11 | 12 | |
|
12 | 13 | def main(): |
@@ -1,3 +1,4 b'' | |||
|
1 | from __future__ import print_function | |
|
1 | 2 | import os |
|
2 | 3 | |
|
3 | 4 | from IPython.kernel.inprocess import InProcessKernelManager |
@@ -5,7 +6,7 b' from IPython.terminal.console.interactiveshell import ZMQTerminalInteractiveShel' | |||
|
5 | 6 | |
|
6 | 7 | |
|
7 | 8 | def print_process_id(): |
|
8 |
print |
|
|
9 | print('Process ID is:', os.getpid()) | |
|
9 | 10 | |
|
10 | 11 | |
|
11 | 12 | def main(): |
@@ -1,6 +1,6 b'' | |||
|
1 | 1 | { |
|
2 | 2 | "metadata": { |
|
3 |
"name": " |
|
|
3 | "name": "" | |
|
4 | 4 | }, |
|
5 | 5 | "nbformat": 3, |
|
6 | 6 | "nbformat_minor": 0, |
@@ -20,6 +20,7 b'' | |||
|
20 | 20 | "cell_type": "code", |
|
21 | 21 | "collapsed": false, |
|
22 | 22 | "input": [ |
|
23 | "from __future__ import print_function\n", | |
|
23 | 24 | "from IPython.lib import backgroundjobs as bg\n", |
|
24 | 25 | "\n", |
|
25 | 26 | "import sys\n", |
@@ -39,15 +40,15 b'' | |||
|
39 | 40 | "def printfunc(interval=1, reps=5):\n", |
|
40 | 41 | " for n in range(reps):\n", |
|
41 | 42 | " time.sleep(interval)\n", |
|
42 |
" print |
|
|
43 | " print('In the background...', n)\n", | |
|
43 | 44 | " sys.stdout.flush()\n", |
|
44 |
" print |
|
|
45 | " print('All done!')\n", | |
|
45 | 46 | " sys.stdout.flush()" |
|
46 | 47 | ], |
|
47 | 48 | "language": "python", |
|
48 | 49 | "metadata": {}, |
|
49 | 50 | "outputs": [], |
|
50 |
"prompt_number": |
|
|
51 | "prompt_number": 1 | |
|
51 | 52 | }, |
|
52 | 53 | { |
|
53 | 54 | "cell_type": "markdown", |
@@ -87,37 +88,9 b'' | |||
|
87 | 88 | "Starting job # 4 in a separate thread.\n", |
|
88 | 89 | "Starting job # 5 in a separate thread.\n" |
|
89 | 90 | ] |
|
90 | }, | |
|
91 | { | |
|
92 | "output_type": "stream", | |
|
93 | "stream": "stdout", | |
|
94 | "text": [ | |
|
95 | "In the background... 0\n" | |
|
96 | ] | |
|
97 | }, | |
|
98 | { | |
|
99 | "output_type": "stream", | |
|
100 | "stream": "stdout", | |
|
101 | "text": [ | |
|
102 | "In the background... 1\n" | |
|
103 | ] | |
|
104 | }, | |
|
105 | { | |
|
106 | "output_type": "stream", | |
|
107 | "stream": "stdout", | |
|
108 | "text": [ | |
|
109 | "In the background... 2\n" | |
|
110 | ] | |
|
111 | }, | |
|
112 | { | |
|
113 | "output_type": "stream", | |
|
114 | "stream": "stdout", | |
|
115 | "text": [ | |
|
116 | "All done!\n" | |
|
117 | ] | |
|
118 | 91 | } |
|
119 | 92 | ], |
|
120 |
"prompt_number": |
|
|
93 | "prompt_number": 2 | |
|
121 | 94 | }, |
|
122 | 95 | { |
|
123 | 96 | "cell_type": "markdown", |
@@ -139,19 +112,27 b'' | |||
|
139 | 112 | "output_type": "stream", |
|
140 | 113 | "stream": "stdout", |
|
141 | 114 | "text": [ |
|
142 | "Completed jobs:\n", | |
|
143 | "0 : <function sleepfunc at 0x30e1578>\n", | |
|
144 | "2 : <function sleepfunc at 0x30e1578>\n", | |
|
115 | "In the background... 0\n", | |
|
116 | "Running jobs:" | |
|
117 | ] | |
|
118 | }, | |
|
119 | { | |
|
120 | "output_type": "stream", | |
|
121 | "stream": "stdout", | |
|
122 | "text": [ | |
|
123 | "\n", | |
|
124 | "0 : <function sleepfunc at 0x7f2a1c9963b0>\n", | |
|
125 | "2 : <function sleepfunc at 0x7f2a1c9963b0>\n", | |
|
145 | 126 | "3 : printfunc(1,3)\n", |
|
127 | "5 : <function diefunc at 0x7f2a1c996440>\n", | |
|
146 | 128 | "\n", |
|
147 | 129 | "Dead jobs:\n", |
|
148 |
"4 : |
|
|
149 | "5 : <function diefunc at 0x304d488>\n", | |
|
130 | "4 : <function diefunc at 0x7f2a1c996440>\n", | |
|
150 | 131 | "\n" |
|
151 | 132 | ] |
|
152 | 133 | } |
|
153 | 134 | ], |
|
154 |
"prompt_number": 3 |
|
|
135 | "prompt_number": 3 | |
|
155 | 136 | }, |
|
156 | 137 | { |
|
157 | 138 | "cell_type": "markdown", |
@@ -170,8 +151,18 b'' | |||
|
170 | 151 | ], |
|
171 | 152 | "language": "python", |
|
172 | 153 | "metadata": {}, |
|
173 |
"outputs": [ |
|
|
174 | "prompt_number": 43 | |
|
154 | "outputs": [ | |
|
155 | { | |
|
156 | "output_type": "stream", | |
|
157 | "stream": "stdout", | |
|
158 | "text": [ | |
|
159 | "In the background... 1\n", | |
|
160 | "In the background... 2\n", | |
|
161 | "All done!\n" | |
|
162 | ] | |
|
163 | } | |
|
164 | ], | |
|
165 | "prompt_number": 4 | |
|
175 | 166 | }, |
|
176 | 167 | { |
|
177 | 168 | "cell_type": "markdown", |
@@ -193,29 +184,15 b'' | |||
|
193 | 184 | "metadata": {}, |
|
194 | 185 | "outputs": [ |
|
195 | 186 | { |
|
196 | "output_type": "stream", | |
|
197 | "stream": "stdout", | |
|
198 | "text": [ | |
|
199 | "Status of diejob1: Dead (Exception), call jobs.traceback() for details\n", | |
|
200 | "<span class=\"ansired\">---------------------------------------------------------------------------</span>\n", | |
|
201 | "<span class=\"ansired\">Exception</span> Traceback (most recent call last)\n", | |
|
202 | "<span class=\"ansigreen\">/home/fperez/usr/lib/python2.6/site-packages/IPython/lib/backgroundjobs.py</span> in <span class=\"ansicyan\">call</span><span class=\"ansiblue\">(self)</span>\n", | |
|
203 | "<span class=\"ansigreen\"> 462</span> <span class=\"ansiyellow\"></span>\n", | |
|
204 | "<span class=\"ansigreen\"> 463</span> <span class=\"ansigreen\">def</span> call<span class=\"ansiyellow\">(</span>self<span class=\"ansiyellow\">)</span><span class=\"ansiyellow\">:</span><span class=\"ansiyellow\"></span>\n", | |
|
205 | "<span class=\"ansigreen\">--> 464</span><span class=\"ansiyellow\"> </span><span class=\"ansigreen\">return</span> self<span class=\"ansiyellow\">.</span>func<span class=\"ansiyellow\">(</span><span class=\"ansiyellow\">*</span>self<span class=\"ansiyellow\">.</span>args<span class=\"ansiyellow\">,</span> <span class=\"ansiyellow\">**</span>self<span class=\"ansiyellow\">.</span>kwargs<span class=\"ansiyellow\">)</span><span class=\"ansiyellow\"></span>\n", | |
|
206 | "\n", | |
|
207 | "<span class=\"ansigreen\">/home/fperez/ipython/ipython/docs/examples/lib/<ipython-input-15-54795a097787></span> in <span class=\"ansicyan\">diefunc</span><span class=\"ansiblue\">(interval, *a, **kw)</span>\n", | |
|
208 | "<span class=\"ansigreen\"> 14</span> <span class=\"ansigreen\">def</span> diefunc<span class=\"ansiyellow\">(</span>interval<span class=\"ansiyellow\">=</span><span class=\"ansicyan\">2</span><span class=\"ansiyellow\">,</span> <span class=\"ansiyellow\">*</span>a<span class=\"ansiyellow\">,</span> <span class=\"ansiyellow\">**</span>kw<span class=\"ansiyellow\">)</span><span class=\"ansiyellow\">:</span><span class=\"ansiyellow\"></span>\n", | |
|
209 | "<span class=\"ansigreen\"> 15</span> time<span class=\"ansiyellow\">.</span>sleep<span class=\"ansiyellow\">(</span>interval<span class=\"ansiyellow\">)</span><span class=\"ansiyellow\"></span>\n", | |
|
210 | "<span class=\"ansigreen\">---> 16</span><span class=\"ansiyellow\"> </span><span class=\"ansigreen\">raise</span> Exception<span class=\"ansiyellow\">(</span><span class=\"ansiblue\">"Dead job with interval %s"</span> <span class=\"ansiyellow\">%</span> interval<span class=\"ansiyellow\">)</span><span class=\"ansiyellow\"></span>\n", | |
|
211 | "<span class=\"ansigreen\"> 17</span> <span class=\"ansiyellow\"></span>\n", | |
|
212 | "<span class=\"ansigreen\"> 18</span> <span class=\"ansigreen\">def</span> printfunc<span class=\"ansiyellow\">(</span>interval<span class=\"ansiyellow\">=</span><span class=\"ansicyan\">1</span><span class=\"ansiyellow\">,</span> reps<span class=\"ansiyellow\">=</span><span class=\"ansicyan\">5</span><span class=\"ansiyellow\">)</span><span class=\"ansiyellow\">:</span><span class=\"ansiyellow\"></span>\n", | |
|
213 | "\n", | |
|
214 | "<span class=\"ansired\">Exception</span>: Dead job with interval 1\n" | |
|
187 | "ename": "SyntaxError", | |
|
188 | "evalue": "invalid syntax (<ipython-input-5-a90bd59af669>, line 1)", | |
|
189 | "output_type": "pyerr", | |
|
190 | "traceback": [ | |
|
191 | "\u001b[1;36m File \u001b[1;32m\"<ipython-input-5-a90bd59af669>\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m print \"Status of diejob1:\", diejob1.status\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n" | |
|
215 | 192 | ] |
|
216 | 193 | } |
|
217 | 194 | ], |
|
218 |
"prompt_number": |
|
|
195 | "prompt_number": 5 | |
|
219 | 196 | }, |
|
220 | 197 | { |
|
221 | 198 | "cell_type": "markdown", |
@@ -237,44 +214,44 b'' | |||
|
237 | 214 | "output_type": "stream", |
|
238 | 215 | "stream": "stdout", |
|
239 | 216 | "text": [ |
|
240 |
"Traceback for: |
|
|
241 |
" |
|
|
242 |
" |
|
|
243 | "<span class=\"ansigreen\">/home/fperez/usr/lib/python2.6/site-packages/IPython/lib/backgroundjobs.py</span> in <span class=\"ansicyan\">call</span><span class=\"ansiblue\">(self)</span>\n", | |
|
244 | "<span class=\"ansigreen\"> 462</span> <span class=\"ansiyellow\"></span>\n", | |
|
245 | "<span class=\"ansigreen\"> 463</span> <span class=\"ansigreen\">def</span> call<span class=\"ansiyellow\">(</span>self<span class=\"ansiyellow\">)</span><span class=\"ansiyellow\">:</span><span class=\"ansiyellow\"></span>\n", | |
|
246 | "<span class=\"ansigreen\">--> 464</span><span class=\"ansiyellow\"> </span><span class=\"ansigreen\">return</span> self<span class=\"ansiyellow\">.</span>func<span class=\"ansiyellow\">(</span><span class=\"ansiyellow\">*</span>self<span class=\"ansiyellow\">.</span>args<span class=\"ansiyellow\">,</span> <span class=\"ansiyellow\">**</span>self<span class=\"ansiyellow\">.</span>kwargs<span class=\"ansiyellow\">)</span><span class=\"ansiyellow\"></span>\n", | |
|
217 | "Traceback for: <BackgroundJob #4: <function diefunc at 0x7f2a1c996440>>\n", | |
|
218 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n", | |
|
219 | "\u001b[1;31mException\u001b[0m Traceback (most recent call last)\n", | |
|
220 | "\u001b[1;32m/home/takluyver/.local/lib/python3.3/site-packages/IPython/lib/backgroundjobs.py\u001b[0m in \u001b[0;36mcall\u001b[1;34m(self)\u001b[0m\n", | |
|
221 | "\u001b[0;32m 489\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", | |
|
222 | "\u001b[0;32m 490\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mcall\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
|
223 | "\u001b[1;32m--> 491\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
|
224 | "\u001b[0m\n", | |
|
225 | "\u001b[1;32m<ipython-input-1-7391f8ae281b>\u001b[0m in \u001b[0;36mdiefunc\u001b[1;34m(interval, *a, **kw)\u001b[0m\n", | |
|
226 | "\u001b[0;32m 14\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mdiefunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minterval\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m*\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkw\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
|
227 | "\u001b[0;32m 15\u001b[0m \u001b[0mtime\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msleep\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minterval\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
|
228 | "\u001b[1;32m---> 16\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Dead job with interval %s\"\u001b[0m \u001b[1;33m%\u001b[0m \u001b[0minterval\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
|
229 | "\u001b[0m\u001b[0;32m 17\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", | |
|
230 | "\u001b[0;32m 18\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mprintfunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minterval\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mreps\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
|
247 | 231 | "\n", |
|
248 | "<span class=\"ansigreen\">/home/fperez/ipython/ipython/docs/examples/lib/<ipython-input-15-54795a097787></span> in <span class=\"ansicyan\">diefunc</span><span class=\"ansiblue\">(interval, *a, **kw)</span>\n", | |
|
249 | "<span class=\"ansigreen\"> 14</span> <span class=\"ansigreen\">def</span> diefunc<span class=\"ansiyellow\">(</span>interval<span class=\"ansiyellow\">=</span><span class=\"ansicyan\">2</span><span class=\"ansiyellow\">,</span> <span class=\"ansiyellow\">*</span>a<span class=\"ansiyellow\">,</span> <span class=\"ansiyellow\">**</span>kw<span class=\"ansiyellow\">)</span><span class=\"ansiyellow\">:</span><span class=\"ansiyellow\"></span>\n", | |
|
250 | "<span class=\"ansigreen\"> 15</span> time<span class=\"ansiyellow\">.</span>sleep<span class=\"ansiyellow\">(</span>interval<span class=\"ansiyellow\">)</span><span class=\"ansiyellow\"></span>\n", | |
|
251 | "<span class=\"ansigreen\">---> 16</span><span class=\"ansiyellow\"> </span><span class=\"ansigreen\">raise</span> Exception<span class=\"ansiyellow\">(</span><span class=\"ansiblue\">"Dead job with interval %s"</span> <span class=\"ansiyellow\">%</span> interval<span class=\"ansiyellow\">)</span><span class=\"ansiyellow\"></span>\n", | |
|
252 | "<span class=\"ansigreen\"> 17</span> <span class=\"ansiyellow\"></span>\n", | |
|
253 | "<span class=\"ansigreen\"> 18</span> <span class=\"ansigreen\">def</span> printfunc<span class=\"ansiyellow\">(</span>interval<span class=\"ansiyellow\">=</span><span class=\"ansicyan\">1</span><span class=\"ansiyellow\">,</span> reps<span class=\"ansiyellow\">=</span><span class=\"ansicyan\">5</span><span class=\"ansiyellow\">)</span><span class=\"ansiyellow\">:</span><span class=\"ansiyellow\"></span>\n", | |
|
232 | "\u001b[1;31mException\u001b[0m: Dead job with interval 1\n", | |
|
254 | 233 | "\n", |
|
255 | "<span class=\"ansired\">Exception</span>: Dead job with interval 1\n", | |
|
234 | "Traceback for: <BackgroundJob #5: <function diefunc at 0x7f2a1c996440>>\n", | |
|
235 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n", | |
|
236 | "\u001b[1;31mException\u001b[0m Traceback (most recent call last)\n", | |
|
237 | "\u001b[1;32m/home/takluyver/.local/lib/python3.3/site-packages/IPython/lib/backgroundjobs.py\u001b[0m in \u001b[0;36mcall\u001b[1;34m(self)\u001b[0m\n", | |
|
238 | "\u001b[0;32m 489\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", | |
|
239 | "\u001b[0;32m 490\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mcall\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
|
240 | "\u001b[1;32m--> 491\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
|
241 | "\u001b[0m\n", | |
|
242 | "\u001b[1;32m<ipython-input-1-7391f8ae281b>\u001b[0m in \u001b[0;36mdiefunc\u001b[1;34m(interval, *a, **kw)\u001b[0m\n", | |
|
243 | "\u001b[0;32m 14\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mdiefunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minterval\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m*\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkw\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
|
244 | "\u001b[0;32m 15\u001b[0m \u001b[0mtime\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msleep\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minterval\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
|
245 | "\u001b[1;32m---> 16\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Dead job with interval %s\"\u001b[0m \u001b[1;33m%\u001b[0m \u001b[0minterval\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
|
246 | "\u001b[0m\u001b[0;32m 17\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", | |
|
247 | "\u001b[0;32m 18\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mprintfunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minterval\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mreps\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
|
256 | 248 | "\n", |
|
257 | "Traceback for: <BackgroundJob #5: <function diefunc at 0x30df758>>\n", | |
|
258 | "<span class=\"ansired\">---------------------------------------------------------------------------</span>\n", | |
|
259 | "<span class=\"ansired\">Exception</span> Traceback (most recent call last)\n", | |
|
260 | "<span class=\"ansigreen\">/home/fperez/usr/lib/python2.6/site-packages/IPython/lib/backgroundjobs.py</span> in <span class=\"ansicyan\">call</span><span class=\"ansiblue\">(self)</span>\n", | |
|
261 | "<span class=\"ansigreen\"> 462</span> <span class=\"ansiyellow\"></span>\n", | |
|
262 | "<span class=\"ansigreen\"> 463</span> <span class=\"ansigreen\">def</span> call<span class=\"ansiyellow\">(</span>self<span class=\"ansiyellow\">)</span><span class=\"ansiyellow\">:</span><span class=\"ansiyellow\"></span>\n", | |
|
263 | "<span class=\"ansigreen\">--> 464</span><span class=\"ansiyellow\"> </span><span class=\"ansigreen\">return</span> self<span class=\"ansiyellow\">.</span>func<span class=\"ansiyellow\">(</span><span class=\"ansiyellow\">*</span>self<span class=\"ansiyellow\">.</span>args<span class=\"ansiyellow\">,</span> <span class=\"ansiyellow\">**</span>self<span class=\"ansiyellow\">.</span>kwargs<span class=\"ansiyellow\">)</span><span class=\"ansiyellow\"></span>\n", | |
|
264 | "\n", | |
|
265 | "<span class=\"ansigreen\">/home/fperez/ipython/ipython/docs/examples/lib/<ipython-input-15-54795a097787></span> in <span class=\"ansicyan\">diefunc</span><span class=\"ansiblue\">(interval, *a, **kw)</span>\n", | |
|
266 | "<span class=\"ansigreen\"> 14</span> <span class=\"ansigreen\">def</span> diefunc<span class=\"ansiyellow\">(</span>interval<span class=\"ansiyellow\">=</span><span class=\"ansicyan\">2</span><span class=\"ansiyellow\">,</span> <span class=\"ansiyellow\">*</span>a<span class=\"ansiyellow\">,</span> <span class=\"ansiyellow\">**</span>kw<span class=\"ansiyellow\">)</span><span class=\"ansiyellow\">:</span><span class=\"ansiyellow\"></span>\n", | |
|
267 | "<span class=\"ansigreen\"> 15</span> time<span class=\"ansiyellow\">.</span>sleep<span class=\"ansiyellow\">(</span>interval<span class=\"ansiyellow\">)</span><span class=\"ansiyellow\"></span>\n", | |
|
268 | "<span class=\"ansigreen\">---> 16</span><span class=\"ansiyellow\"> </span><span class=\"ansigreen\">raise</span> Exception<span class=\"ansiyellow\">(</span><span class=\"ansiblue\">"Dead job with interval %s"</span> <span class=\"ansiyellow\">%</span> interval<span class=\"ansiyellow\">)</span><span class=\"ansiyellow\"></span>\n", | |
|
269 | "<span class=\"ansigreen\"> 17</span> <span class=\"ansiyellow\"></span>\n", | |
|
270 | "<span class=\"ansigreen\"> 18</span> <span class=\"ansigreen\">def</span> printfunc<span class=\"ansiyellow\">(</span>interval<span class=\"ansiyellow\">=</span><span class=\"ansicyan\">1</span><span class=\"ansiyellow\">,</span> reps<span class=\"ansiyellow\">=</span><span class=\"ansicyan\">5</span><span class=\"ansiyellow\">)</span><span class=\"ansiyellow\">:</span><span class=\"ansiyellow\"></span>\n", | |
|
271 | "\n", | |
|
272 | "<span class=\"ansired\">Exception</span>: Dead job with interval 2\n", | |
|
249 | "\u001b[1;31mException\u001b[0m: Dead job with interval 2\n", | |
|
273 | 250 | "\n" |
|
274 | 251 | ] |
|
275 | 252 | } |
|
276 | 253 | ], |
|
277 |
"prompt_number": |
|
|
254 | "prompt_number": 6 | |
|
278 | 255 | }, |
|
279 | 256 | { |
|
280 | 257 | "cell_type": "markdown", |
@@ -296,11 +273,12 b'' | |||
|
296 | 273 | "output_type": "stream", |
|
297 | 274 | "stream": "stdout", |
|
298 | 275 | "text": [ |
|
299 | "No jobs to flush.\n" | |
|
276 | "Flushing 3 Completed jobs.\n", | |
|
277 | "Flushing 2 Dead jobs.\n" | |
|
300 | 278 | ] |
|
301 | 279 | } |
|
302 | 280 | ], |
|
303 |
"prompt_number": |
|
|
281 | "prompt_number": 7 | |
|
304 | 282 | }, |
|
305 | 283 | { |
|
306 | 284 | "cell_type": "markdown", |
@@ -318,7 +296,7 b'' | |||
|
318 | 296 | "language": "python", |
|
319 | 297 | "metadata": {}, |
|
320 | 298 | "outputs": [], |
|
321 |
"prompt_number": |
|
|
299 | "prompt_number": 8 | |
|
322 | 300 | }, |
|
323 | 301 | { |
|
324 | 302 | "cell_type": "markdown", |
@@ -332,10 +310,10 b'' | |||
|
332 | 310 | "collapsed": false, |
|
333 | 311 | "input": [ |
|
334 | 312 | "j = jobs.new(sleepfunc, 2)\n", |
|
335 |
"print |
|
|
313 | "print(\"Will wait for j now...\")\n", | |
|
336 | 314 | "sys.stdout.flush()\n", |
|
337 | 315 | "j.join()\n", |
|
338 |
"print |
|
|
316 | "print(\"Result from j:\")\n", | |
|
339 | 317 | "j.result" |
|
340 | 318 | ], |
|
341 | 319 | "language": "python", |
@@ -345,7 +323,7 b'' | |||
|
345 | 323 | "output_type": "stream", |
|
346 | 324 | "stream": "stdout", |
|
347 | 325 | "text": [ |
|
348 |
"Starting job # |
|
|
326 | "Starting job # 0 in a separate thread.\n", | |
|
349 | 327 | "Will wait for j now...\n" |
|
350 | 328 | ] |
|
351 | 329 | }, |
@@ -357,14 +335,15 b'' | |||
|
357 | 335 | ] |
|
358 | 336 | }, |
|
359 | 337 | { |
|
338 | "metadata": {}, | |
|
360 | 339 | "output_type": "pyout", |
|
361 |
"prompt_number": |
|
|
340 | "prompt_number": 9, | |
|
362 | 341 | "text": [ |
|
363 | "{'args': (), 'interval': 2, 'kwargs': {}}" | |
|
342 | "{'kwargs': {}, 'args': (), 'interval': 2}" | |
|
364 | 343 | ] |
|
365 | 344 | } |
|
366 | 345 | ], |
|
367 |
"prompt_number": |
|
|
346 | "prompt_number": 9 | |
|
368 | 347 | }, |
|
369 | 348 | { |
|
370 | 349 | "cell_type": "code", |
@@ -10,7 +10,6 b' In [6]: %run gui-qt.py' | |||
|
10 | 10 | Ref: Modified from http://zetcode.com/tutorials/pyqt4/firstprograms/ |
|
11 | 11 | """ |
|
12 | 12 | |
|
13 | import sys | |
|
14 | 13 | from PyQt4 import QtGui, QtCore |
|
15 | 14 | |
|
16 | 15 | class SimpleWindow(QtGui.QWidget): |
@@ -8,7 +8,10 b' In [5]: %gui tk' | |||
|
8 | 8 | In [6]: %run gui-tk.py |
|
9 | 9 | """ |
|
10 | 10 | |
|
11 | from Tkinter import * | |
|
11 | try: | |
|
12 | from tkinter import * # Python 3 | |
|
13 | except ImportError: | |
|
14 | from Tkinter import * # Python 2 | |
|
12 | 15 | |
|
13 | 16 | class MyApp: |
|
14 | 17 |
@@ -2,7 +2,6 b'' | |||
|
2 | 2 | # Imports |
|
3 | 3 | #----------------------------------------------------------------------------- |
|
4 | 4 | |
|
5 | import subprocess | |
|
6 | 5 | import sys |
|
7 | 6 | |
|
8 | 7 | from IPython.lib.kernel import connect_qtconsole |
@@ -42,7 +41,7 b' class InternalIPKernel(object):' | |||
|
42 | 41 | |
|
43 | 42 | def print_namespace(self, evt=None): |
|
44 | 43 | print("\n***Variables in User namespace***") |
|
45 |
for k, v in self.namespace. |
|
|
44 | for k, v in self.namespace.items(): | |
|
46 | 45 | if k not in self._init_keys and not k.startswith('_'): |
|
47 | 46 | print('%s -> %r' % (k, v)) |
|
48 | 47 | sys.stdout.flush() |
@@ -153,9 +153,8 b'' | |||
|
153 | 153 | "collapsed": false, |
|
154 | 154 | "input": [ |
|
155 | 155 | "# Python 3 compat\n", |
|
156 |
" |
|
|
157 | " raw_input\n", | |
|
158 | "except NameError:\n", | |
|
156 | "import sys\n", | |
|
157 | "if sys.version_info[0] >= 3:\n", | |
|
159 | 158 | " raw_input = input" |
|
160 | 159 | ], |
|
161 | 160 | "language": "python", |
@@ -157,7 +157,7 b'' | |||
|
157 | 157 | " # transform the input to executable Python\n", |
|
158 | 158 | " code = self.shell.input_transformer_manager.transform_cell(cell.input)\n", |
|
159 | 159 | " # run the code in themodule\n", |
|
160 |
" exec |
|
|
160 | " exec(code, mod.__dict__)\n", | |
|
161 | 161 | " finally:\n", |
|
162 | 162 | " self.shell.user_ns = save_user_ns\n", |
|
163 | 163 | " return mod\n" |
@@ -989,24 +989,6 b'' | |||
|
989 | 989 | "cell_type": "markdown", |
|
990 | 990 | "metadata": {}, |
|
991 | 991 | "source": [ |
|
992 | "By default, `DataFrames` will be represented as text; to enable HTML representations we need to set a print option:" | |
|
993 | ] | |
|
994 | }, | |
|
995 | { | |
|
996 | "cell_type": "code", | |
|
997 | "collapsed": false, | |
|
998 | "input": [ | |
|
999 | "pandas.core.format.set_printoptions(notebook_repr_html=True)" | |
|
1000 | ], | |
|
1001 | "language": "python", | |
|
1002 | "metadata": {}, | |
|
1003 | "outputs": [], | |
|
1004 | "prompt_number": 9 | |
|
1005 | }, | |
|
1006 | { | |
|
1007 | "cell_type": "markdown", | |
|
1008 | "metadata": {}, | |
|
1009 | "source": [ | |
|
1010 | 992 | "Here is a small amount of stock data for APPL:" |
|
1011 | 993 | ] |
|
1012 | 994 | }, |
@@ -67,7 +67,7 b'' | |||
|
67 | 67 | "cell_type": "code", |
|
68 | 68 | "collapsed": false, |
|
69 | 69 | "input": [ |
|
70 |
"%px print |
|
|
70 | "%px print(a)" | |
|
71 | 71 | ], |
|
72 | 72 | "language": "python", |
|
73 | 73 | "metadata": {}, |
@@ -98,7 +98,8 b'' | |||
|
98 | 98 | "cell_type": "code", |
|
99 | 99 | "collapsed": false, |
|
100 | 100 | "input": [ |
|
101 | "%px print >> sys.stderr, \"ERROR\"" | |
|
101 | "%px from __future__ import print_function\n", | |
|
102 | "%px print(\"ERROR\", file=sys.stderr)" | |
|
102 | 103 | ], |
|
103 | 104 | "language": "python", |
|
104 | 105 | "metadata": {}, |
@@ -208,7 +209,7 b'' | |||
|
208 | 209 | "%%px --noblock\n", |
|
209 | 210 | "x = np.linspace(0,np.pi,1000)\n", |
|
210 | 211 | "for n in range(id,12, stride):\n", |
|
211 |
" print |
|
|
212 | " print(n)\n", | |
|
212 | 213 | " plt.plot(x,np.sin(n*x))\n", |
|
213 | 214 | "plt.title(\"Plot %i\" % id)" |
|
214 | 215 | ], |
@@ -248,7 +249,7 b'' | |||
|
248 | 249 | "%%px --group-outputs=engine\n", |
|
249 | 250 | "x = np.linspace(0,np.pi,1000)\n", |
|
250 | 251 | "for n in range(id+1,12, stride):\n", |
|
251 |
" print |
|
|
252 | " print(n)\n", | |
|
252 | 253 | " plt.figure()\n", |
|
253 | 254 | " plt.plot(x,np.sin(n*x))\n", |
|
254 | 255 | " plt.title(\"Plot %i\" % n)" |
@@ -296,6 +297,8 b'' | |||
|
296 | 297 | "cell_type": "code", |
|
297 | 298 | "collapsed": false, |
|
298 | 299 | "input": [ |
|
300 | "from __future__ import print_function\n", | |
|
301 | "\n", | |
|
299 | 302 | "def generate_output():\n", |
|
300 | 303 | " \"\"\"function for testing output\n", |
|
301 | 304 | " \n", |
@@ -305,13 +308,13 b'' | |||
|
305 | 308 | " import sys,os\n", |
|
306 | 309 | " from IPython.display import display, HTML, Math\n", |
|
307 | 310 | " \n", |
|
308 |
" print |
|
|
309 |
" print |
|
|
311 | " print(\"stdout\")\n", | |
|
312 | " print(\"stderr\", file=sys.stderr)\n", | |
|
310 | 313 | " \n", |
|
311 | 314 | " display(HTML(\"<b>HTML</b>\"))\n", |
|
312 | 315 | " \n", |
|
313 |
" print |
|
|
314 |
" print |
|
|
316 | " print(\"stdout2\")\n", | |
|
317 | " print(\"stderr2\", file=sys.stderr)\n", | |
|
315 | 318 | " \n", |
|
316 | 319 | " display(Math(r\"\\alpha=\\beta\"))\n", |
|
317 | 320 | " \n", |
@@ -461,7 +464,7 b'' | |||
|
461 | 464 | "cell_type": "markdown", |
|
462 | 465 | "metadata": {}, |
|
463 | 466 | "source": [ |
|
464 |
"As of IPython 0 |
|
|
467 | "As of IPython 1.0, you can instruct `%%px` to also execute the cell locally.\n", | |
|
465 | 468 | "This is useful for interactive definitions,\n", |
|
466 | 469 | "or if you want to load a data source everywhere,\n", |
|
467 | 470 | "not just on the engines." |
@@ -474,7 +477,7 b'' | |||
|
474 | 477 | "%%px --local\n", |
|
475 | 478 | "import os\n", |
|
476 | 479 | "thispid = os.getpid()\n", |
|
477 |
"print |
|
|
480 | "print(thispid)" | |
|
478 | 481 | ], |
|
479 | 482 | "language": "python", |
|
480 | 483 | "metadata": {}, |
@@ -1,6 +1,6 b'' | |||
|
1 | 1 | { |
|
2 | 2 | "metadata": { |
|
3 |
"name": " |
|
|
3 | "name": "" | |
|
4 | 4 | }, |
|
5 | 5 | "nbformat": 3, |
|
6 | 6 | "nbformat_minor": 0, |
@@ -20,6 +20,7 b'' | |||
|
20 | 20 | "cell_type": "code", |
|
21 | 21 | "collapsed": true, |
|
22 | 22 | "input": [ |
|
23 | "from __future__ import print_function\n", | |
|
23 | 24 | "from IPython.parallel import Client" |
|
24 | 25 | ], |
|
25 | 26 | "language": "python", |
@@ -69,8 +70,8 b'' | |||
|
69 | 70 | "cell_type": "code", |
|
70 | 71 | "collapsed": false, |
|
71 | 72 | "input": [ |
|
72 |
"print |
|
|
73 |
"print |
|
|
73 | "print(\"Submitted tasks:\", hello.msg_ids + world.msg_ids)\n", | |
|
74 | "print(hello.get(), world.get())" | |
|
74 | 75 | ], |
|
75 | 76 | "language": "python", |
|
76 | 77 | "metadata": {}, |
@@ -18,6 +18,7 b'' | |||
|
18 | 18 | "cell_type": "code", |
|
19 | 19 | "collapsed": true, |
|
20 | 20 | "input": [ |
|
21 | "from __future__ import print_function\n", | |
|
21 | 22 | "from IPython.parallel import Client" |
|
22 | 23 | ], |
|
23 | 24 | "language": "python", |
@@ -110,7 +111,7 b'' | |||
|
110 | 111 | "cell_type": "code", |
|
111 | 112 | "collapsed": false, |
|
112 | 113 | "input": [ |
|
113 |
"print |
|
|
114 | "print(\"a, b, c: \", ar.get())" | |
|
114 | 115 | ], |
|
115 | 116 | "language": "python", |
|
116 | 117 | "metadata": {}, |
@@ -1,6 +1,6 b'' | |||
|
1 | 1 | { |
|
2 | 2 | "metadata": { |
|
3 |
"name": " |
|
|
3 | "name": "" | |
|
4 | 4 | }, |
|
5 | 5 | "nbformat": 3, |
|
6 | 6 | "nbformat_minor": 0, |
@@ -18,6 +18,7 b'' | |||
|
18 | 18 | "cell_type": "code", |
|
19 | 19 | "collapsed": true, |
|
20 | 20 | "input": [ |
|
21 | "from __future__ import print_function\n", | |
|
21 | 22 | "from IPython.parallel import Client" |
|
22 | 23 | ], |
|
23 | 24 | "language": "python", |
@@ -42,7 +43,7 b'' | |||
|
42 | 43 | "collapsed": false, |
|
43 | 44 | "input": [ |
|
44 | 45 | "result = v.map(lambda x: 2*x, range(10))\n", |
|
45 |
"print |
|
|
46 | "print(\"Simple, default map: \", list(result))" | |
|
46 | 47 | ], |
|
47 | 48 | "language": "python", |
|
48 | 49 | "metadata": {}, |
@@ -69,9 +70,9 b'' | |||
|
69 | 70 | "collapsed": false, |
|
70 | 71 | "input": [ |
|
71 | 72 | "ar = v.map_async(lambda x: 2*x, range(10))\n", |
|
72 |
"print |
|
|
73 | "print(\"Submitted tasks, got ids: \", ar.msg_ids)\n", | |
|
73 | 74 | "result = ar.get()\n", |
|
74 |
"print |
|
|
75 | "print(\"Using a mapper: \", result)" | |
|
75 | 76 | ], |
|
76 | 77 | "language": "python", |
|
77 | 78 | "metadata": {}, |
@@ -95,7 +96,7 b'' | |||
|
95 | 96 | "def f(x): return 2*x\n", |
|
96 | 97 | "\n", |
|
97 | 98 | "result = f.map(range(10))\n", |
|
98 |
"print |
|
|
99 | "print(\"Using a parallel function: \", result)" | |
|
99 | 100 | ], |
|
100 | 101 | "language": "python", |
|
101 | 102 | "metadata": {}, |
@@ -29,7 +29,7 b'' | |||
|
29 | 29 | "cell_type": "code", |
|
30 | 30 | "collapsed": false, |
|
31 | 31 | "input": [ |
|
32 |
"print |
|
|
32 | "print('hi')" | |
|
33 | 33 | ], |
|
34 | 34 | "language": "python", |
|
35 | 35 | "metadata": {}, |
@@ -180,7 +180,7 b'' | |||
|
180 | 180 | "cell_type": "code", |
|
181 | 181 | "collapsed": false, |
|
182 | 182 | "input": [ |
|
183 | "# press tab after parentheses\n", | |
|
183 | "# press shift-tab after parentheses\n", | |
|
184 | 184 | "int(" |
|
185 | 185 | ], |
|
186 | 186 | "language": "python", |
@@ -199,7 +199,7 b'' | |||
|
199 | 199 | "cell_type": "code", |
|
200 | 200 | "collapsed": false, |
|
201 | 201 | "input": [ |
|
202 | "# pres tab after f\n", | |
|
202 | "# press tab after f\n", | |
|
203 | 203 | "f" |
|
204 | 204 | ], |
|
205 | 205 | "language": "python", |
@@ -218,7 +218,7 b'' | |||
|
218 | 218 | "cell_type": "code", |
|
219 | 219 | "collapsed": false, |
|
220 | 220 | "input": [ |
|
221 | "import sys\n", | |
|
221 | "import sys, time\n", | |
|
222 | 222 | "from IPython.display import clear_output" |
|
223 | 223 | ], |
|
224 | 224 | "language": "python", |
@@ -232,7 +232,7 b'' | |||
|
232 | 232 | "for i in range(10):\n", |
|
233 | 233 | " clear_output()\n", |
|
234 | 234 | " time.sleep(0.25)\n", |
|
235 |
" print |
|
|
235 | " print(i)\n", | |
|
236 | 236 | " sys.stdout.flush()\n", |
|
237 | 237 | " time.sleep(0.25)\n" |
|
238 | 238 | ], |
@@ -247,7 +247,7 b'' | |||
|
247 | 247 | "for i in range(10):\n", |
|
248 | 248 | " clear_output(wait=True)\n", |
|
249 | 249 | " time.sleep(0.25)\n", |
|
250 |
" print |
|
|
250 | " print(i)\n", | |
|
251 | 251 | " sys.stdout.flush()\n" |
|
252 | 252 | ], |
|
253 | 253 | "language": "python", |
General Comments 0
You need to be logged in to leave comments.
Login now