summaryrefslogtreecommitdiff
path: root/doc/numpybook/runcode.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2013-04-06 13:25:26 -0600
committerCharles Harris <charlesr.harris@gmail.com>2013-04-06 13:25:26 -0600
commitbb726ca19f434f5055c0efceefe48d89469fcbbe (patch)
tree889782afaf67fd5acb5f222969251871c0c46e5a /doc/numpybook/runcode.py
parent7441fa50523f5b4a16c854bf004d675e5bd86ab8 (diff)
downloadnumpy-bb726ca19f434f5055c0efceefe48d89469fcbbe.tar.gz
2to3: Apply `print` fixer.
Add `print_function` to all `from __future__ import ...` statements and use the python3 print function syntax everywhere. Closes #3078.
Diffstat (limited to 'doc/numpybook/runcode.py')
-rw-r--r--doc/numpybook/runcode.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/doc/numpybook/runcode.py b/doc/numpybook/runcode.py
index 858168e11..456846cad 100644
--- a/doc/numpybook/runcode.py
+++ b/doc/numpybook/runcode.py
@@ -14,7 +14,7 @@ Options:
-n name of code section (default MyCode)
"""
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import sys
import optparse
@@ -25,8 +25,8 @@ import os
newre = re.compile(r"\\begin_inset Note.*PYNEW\s+\\end_inset", re.DOTALL)
def getoutput(tstr, dic):
- print "\n\nRunning..."
- print tstr,
+ print("\n\nRunning...")
+ print(tstr, end=' ')
tempstr = io.StringIO()
sys.stdout = tempstr
code = compile(tstr, '<input>', 'exec')
@@ -44,8 +44,8 @@ def getoutput(tstr, dic):
else:
res = tempstr.getvalue() + '\n' + repr(res)
if res != '':
- print "\nOutput is"
- print res,
+ print("\nOutput is")
+ print(res, end=' ')
return res
# now find the code in the code segment
@@ -90,7 +90,7 @@ def runpycode(lyxstr, name='MyCode'):
num += 1
if num == 0:
- print "Nothing found for %s" % name
+ print("Nothing found for %s" % name)
return lyxstr
start = 0
@@ -141,7 +141,7 @@ def main(args):
fid = file(args[0])
str = fid.read()
fid.close()
- print "Processing %s" % options.name
+ print("Processing %s" % options.name)
newstr = runpycode(str, options.name)
fid = file(args[0],'w')
fid.write(newstr)