Show More
@@ -196,10 +196,10 b' magic, a cell one and one that works in both modes, using just plain functions:' | |||
|
196 | 196 | def lcmagic(line, cell=None): |
|
197 | 197 | "Magic that works both as %lcmagic and as %%lcmagic" |
|
198 | 198 |
|
|
199 |
|
|
|
199 | print("Called as line magic") | |
|
200 | 200 |
|
|
201 | 201 | else: |
|
202 |
|
|
|
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 |
@@ -216,6 +216,7 b' IPython object:' | |||
|
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 | |
@@ -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 |
General Comments 0
You need to be logged in to leave comments.
Login now