From bb726ca19f434f5055c0efceefe48d89469fcbbe Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sat, 6 Apr 2013 13:25:26 -0600 Subject: 2to3: Apply `print` fixer. Add `print_function` to all `from __future__ import ...` statements and use the python3 print function syntax everywhere. Closes #3078. --- doc/numpybook/runcode.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'doc/numpybook/runcode.py') 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, '', '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) -- cgit v1.2.1