##// END OF EJS Templates
Update some print statements in the docs
Thomas Kluyver -
Show More
@@ -196,10 +196,10 b' magic, a cell one and one that works in both modes, using just plain functions:'
196 def lcmagic(line, cell=None):
196 def lcmagic(line, cell=None):
197 "Magic that works both as %lcmagic and as %%lcmagic"
197 "Magic that works both as %lcmagic and as %%lcmagic"
198 if cell is None:
198 if cell is None:
199 print "Called as line magic"
199 print("Called as line magic")
200 return line
200 return line
201 else:
201 else:
202 print "Called as cell magic"
202 print("Called as cell magic")
203 return line, cell
203 return line, cell
204
204
205 # We delete these to avoid name conflicts for automagic to work
205 # We delete these to avoid name conflicts for automagic to work
@@ -216,6 +216,7 b' IPython object:'
216 # This code can be put in any Python module, it does not require IPython
216 # This code can be put in any Python module, it does not require IPython
217 # itself to be running already. It only creates the magics subclass but
217 # itself to be running already. It only creates the magics subclass but
218 # doesn't instantiate it yet.
218 # doesn't instantiate it yet.
219 from __future__ import print_function
219 from IPython.core.magic import (Magics, magics_class, line_magic,
220 from IPython.core.magic import (Magics, magics_class, line_magic,
220 cell_magic, line_cell_magic)
221 cell_magic, line_cell_magic)
221
222
@@ -226,8 +227,8 b' IPython object:'
226 @line_magic
227 @line_magic
227 def lmagic(self, line):
228 def lmagic(self, line):
228 "my line magic"
229 "my line magic"
229 print "Full access to the main IPython object:", self.shell
230 print("Full access to the main IPython object:", self.shell)
230 print "Variables in the user namespace:", self.shell.user_ns.keys()
231 print("Variables in the user namespace:", list(self.shell.user_ns.keys()))
231 return line
232 return line
232
233
233 @cell_magic
234 @cell_magic
@@ -239,10 +240,10 b' IPython object:'
239 def lcmagic(self, line, cell=None):
240 def lcmagic(self, line, cell=None):
240 "Magic that works both as %lcmagic and as %%lcmagic"
241 "Magic that works both as %lcmagic and as %%lcmagic"
241 if cell is None:
242 if cell is None:
242 print "Called as line magic"
243 print("Called as line magic")
243 return line
244 return line
244 else:
245 else:
245 print "Called as cell magic"
246 print("Called as cell magic")
246 return line, cell
247 return line, cell
247
248
248
249
@@ -288,8 +289,8 b' follows:'
288 .. sourcecode:: python
289 .. sourcecode:: python
289
290
290 def func(self, line):
291 def func(self, line):
291 print "Line magic called with line:", line
292 print("Line magic called with line:", line)
292 print "IPython object:", self.shell
293 print("IPython object:", self.shell)
293
294
294 ip = get_ipython()
295 ip = get_ipython()
295 # Declare this function as the magic %mycommand
296 # Declare this function as the magic %mycommand
@@ -961,7 +962,7 b' standard Python tutorial::'
961 In [3]: ... a, b = 0, 1
962 In [3]: ... a, b = 0, 1
962
963
963 In [4]: >>> while b < 10:
964 In [4]: >>> while b < 10:
964 ...: ... print b
965 ...: ... print(b)
965 ...: ... a, b = b, a+b
966 ...: ... a, b = b, a+b
966 ...:
967 ...:
967 1
968 1
@@ -62,7 +62,7 b' mechanism, this is automatically stored::'
62
62
63 hello - this is a temporary file
63 hello - this is a temporary file
64
64
65 Out[1]: "print 'hello - this is a temporary file'\n"
65 Out[1]: "print('hello - this is a temporary file')\n"
66
66
67 Now, if you call ``%edit -p``, IPython tries to open an editor with the
67 Now, if you call ``%edit -p``, IPython tries to open an editor with the
68 same data as the last time you used %edit. So if you haven't used %edit
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 hello - now I made some changes
83 hello - now I made some changes
84
84
85 Out[2]: "print 'hello - now I made some changes'\n"
85 Out[2]: "print('hello - now I made some changes')\n"
86
86
87 In [3]: edit _1
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 IPython version control at work :)
95 IPython version control at work :)
96
96
97 Out[3]: "print 'hello - this is a temporary file'\nprint 'IPython version control at work :)'\n"
97 Out[3]: "print('hello - this is a temporary file')\nprint('IPython version control at work :)')\n"
98
98
99
99
100 This section was written after a contribution by Alexander Belchenko on
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