##// END OF EJS Templates
Fix many py2-style prints in docs and commented code....
Antony Lee -
Show More
@@ -19,7 +19,7 b' example, you could use a startup file like this::'
19 19
20 20 def calljed(self,filename, linenum):
21 21 "My editor hook calls the jed editor directly."
22 print "Calling my own editor, jed ..."
22 print("Calling my own editor, jed ...")
23 23 if os.system('jed +%d %s' % (linenum,filename)) != 0:
24 24 raise TryNext()
25 25
@@ -111,7 +111,7 b' class CommandChainDispatcher:'
111 111 TryNext"""
112 112 last_exc = TryNext()
113 113 for prio,cmd in self.chain:
114 #print "prio",prio,"cmd",cmd #dbg
114 # print("prio",prio,"cmd",cmd) # dbg
115 115 try:
116 116 return cmd(*args, **kw)
117 117 except TryNext as exc:
@@ -320,7 +320,7 b' class InputSplitter(object):'
320 320 prompt = '>>> ' + indent
321 321 line = indent + raw_input(prompt)
322 322 isp.push(line)
323 print 'Input source was:\n', isp.source_reset(),
323 print('Input source was:\n', isp.source_reset())
324 324 """
325 325 # A cache for storing the current indentation
326 326 # The first value stores the most recently processed source input
@@ -191,7 +191,7 b' which already exists. But you must first start the logging process with'
191 191 def log_write(self, data, kind='input'):
192 192 """Write data to the log file, if active"""
193 193
194 #print 'data: %r' % data # dbg
194 # print('data: %r' % data) # dbg
195 195 if self.log_active and data:
196 196 write = self.logfile.write
197 197 if kind=='input':
@@ -452,7 +452,7 b' class CodeMagics(Magics):'
452 452 # Load the parameter given as a variable. If not a string,
453 453 # process it as an object instead (below)
454 454
455 #print '*** args',args,'type',type(args) # dbg
455 # print('*** args',args,'type',type(args)) # dbg
456 456 data = eval(args, shell.user_ns)
457 457 if not isinstance(data, str):
458 458 raise DataIsObject
@@ -636,8 +636,8 b' class CodeMagics(Magics):'
636 636
637 637 In [1]: edit
638 638 Editing... done. Executing edited code...
639 Out[1]: 'def foo():\\n print "foo() was defined in an editing
640 session"\\n'
639 Out[1]: 'def foo():\\n print("foo() was defined in an editing
640 session")\\n'
641 641
642 642 We can then call the function foo()::
643 643
@@ -661,21 +661,21 b' class CodeMagics(Magics):'
661 661 In [5]: edit
662 662 Editing... done. Executing edited code...
663 663 hello
664 Out[5]: "print 'hello'\\n"
664 Out[5]: "print('hello')\\n"
665 665
666 666 Now we call it again with the previous output (stored in _)::
667 667
668 668 In [6]: edit _
669 669 Editing... done. Executing edited code...
670 670 hello world
671 Out[6]: "print 'hello world'\\n"
671 Out[6]: "print('hello world')\\n"
672 672
673 673 Now we call it with the output #8 (stored in _8, also as Out[8])::
674 674
675 675 In [7]: edit _8
676 676 Editing... done. Executing edited code...
677 677 hello again
678 Out[7]: "print 'hello again'\\n"
678 Out[7]: "print('hello again')\\n"
679 679
680 680
681 681 Changing the default editor hook:
@@ -1256,7 +1256,7 b' class ExecutionMagics(Magics):'
1256 1256 Wall time: 1.37
1257 1257 Out[3]: 499999500000L
1258 1258
1259 In [4]: %time print 'hello world'
1259 In [4]: %time print('hello world')
1260 1260 hello world
1261 1261 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1262 1262 Wall time: 0.00
@@ -1406,9 +1406,9 b' class ExecutionMagics(Magics):'
1406 1406 44: x=1
1407 1407 45: y=3
1408 1408 46: z=x+y
1409 47: print x
1409 47: print(x)
1410 1410 48: a=5
1411 49: print 'x',x,'y',y
1411 49: print('x',x,'y',y)
1412 1412
1413 1413 you can create a macro with lines 44 through 47 (included) and line 49
1414 1414 called my_macro with::
@@ -1428,7 +1428,7 b' class ExecutionMagics(Magics):'
1428 1428
1429 1429 You can view a macro's contents by explicitly printing it with::
1430 1430
1431 print macro_name
1431 print(macro_name)
1432 1432
1433 1433 """
1434 1434 opts,args = self.parse_options(parameter_s,'rq',mode='list')
@@ -1439,7 +1439,7 b' class ExecutionMagics(Magics):'
1439 1439 "%macro insufficient args; usage '%macro name n1-n2 n3-4...")
1440 1440 name, codefrom = args[0], " ".join(args[1:])
1441 1441
1442 #print 'rng',ranges # dbg
1442 # print('rng',ranges) # dbg
1443 1443 try:
1444 1444 lines = self.shell.find_user_code(codefrom, 'r' in opts)
1445 1445 except (ValueError, TypeError) as e:
@@ -128,7 +128,7 b' class HistoryMagics(Magics):'
128 128
129 129 In [6]: %history -n 4-6
130 130 4:a = 12
131 5:print a**2
131 5:print(a**2)
132 132 6:%history -n 4-6
133 133
134 134 """
@@ -43,7 +43,7 b' class NamespaceMagics(Magics):'
43 43
44 44 '%pinfo object' is just a synonym for object? or ?object."""
45 45
46 #print 'pinfo par: <%s>' % parameter_s # dbg
46 # print('pinfo par: <%s>' % parameter_s) # dbg
47 47 # detail_level: 0 -> obj? , 1 -> obj??
48 48 detail_level = 0
49 49 # We need to detect if we got called as 'pinfo pinfo foo', which can
@@ -1196,7 +1196,7 b' class Inspector(Colorable):'
1196 1196
1197 1197 - list_types(False): list all available object types for object matching.
1198 1198 """
1199 #print 'ps pattern:<%r>' % pattern # dbg
1199 # print('ps pattern:<%r>' % pattern) # dbg
1200 1200
1201 1201 # defaults
1202 1202 type_pattern = 'all'
@@ -1225,7 +1225,7 b' class Inspector(Colorable):'
1225 1225 raise ValueError('invalid namespace <%s>. Valid names: %s' %
1226 1226 (name,ns_table.keys()))
1227 1227
1228 #print 'type_pattern:',type_pattern # dbg
1228 # print('type_pattern:',type_pattern) # dbg
1229 1229 search_result, namespaces_seen = set(), set()
1230 1230 for ns_name in ns_search:
1231 1231 ns = ns_table[ns_name]
@@ -122,8 +122,8 b' def _detect_screen_size(screen_lines_def):'
122 122 termios.tcsetattr(sys.stdout,termios.TCSANOW,term_flags)
123 123 # Now we have what we needed: the screen size in rows/columns
124 124 return screen_lines_real
125 #print '***Screen size:',screen_lines_real,'lines x',\
126 #screen_cols,'columns.' # dbg
125 # print('***Screen size:',screen_lines_real,'lines x',
126 # screen_cols,'columns.') # dbg
127 127
128 128 def pager_page(strng, start=0, screen_lines=0, pager_cmd=None):
129 129 """Display a string, piping through a pager after a certain length.
@@ -179,9 +179,9 b' def pager_page(strng, start=0, screen_lines=0, pager_cmd=None):'
179 179 print(str_toprint)
180 180 return
181 181
182 #print 'numlines',numlines,'screenlines',screen_lines # dbg
182 # print('numlines',numlines,'screenlines',screen_lines) # dbg
183 183 if numlines <= screen_lines :
184 #print '*** normal print' # dbg
184 # print('*** normal print') # dbg
185 185 print(str_toprint)
186 186 else:
187 187 # Try to open pager and default to internal one if that fails.
@@ -240,7 +240,7 b' class PrefilterManager(Configurable):'
240 240
241 241 This implements the checker/handler part of the prefilter pipe.
242 242 """
243 # print "prefilter_line_info: ", line_info
243 # print("prefilter_line_info: ", line_info)
244 244 handler = self.find_handler(line_info)
245 245 return handler.handle(line_info)
246 246
@@ -267,7 +267,7 b' class PrefilterManager(Configurable):'
267 267 transformers and then the checkers/handlers.
268 268 """
269 269
270 # print "prefilter_line: ", line, continue_prompt
270 # print("prefilter_line: ", line, continue_prompt)
271 271 # All handlers *must* return a value, even if it's blank ('').
272 272
273 273 # save the line away in case we crash, so the post-mortem handler can
@@ -300,7 +300,7 b' class PrefilterManager(Configurable):'
300 300 return normal_handler.handle(line_info)
301 301
302 302 prefiltered = self.prefilter_line_info(line_info)
303 # print "prefiltered line: %r" % prefiltered
303 # print("prefiltered line: %r" % prefiltered)
304 304 return prefiltered
305 305
306 306 def prefilter_lines(self, lines, continue_prompt=False):
@@ -544,7 +544,7 b' class PrefilterHandler(Configurable):'
544 544 )
545 545
546 546 def handle(self, line_info):
547 # print "normal: ", line_info
547 # print("normal: ", line_info)
548 548 """Handle normal input lines. Use as a template for handlers."""
549 549
550 550 # With autoindent on, we need some way to exit the input loop, and I
@@ -224,7 +224,7 b' def mpl_runner(safe_execfile):'
224 224 import matplotlib
225 225 import matplotlib.pyplot as plt
226 226
227 #print '*** Matplotlib runner ***' # dbg
227 # print('*** Matplotlib runner ***') # dbg
228 228 # turn off rendering until end of script
229 229 with matplotlib.rc_context({"interactive": False}):
230 230 safe_execfile(fname, *where, **kw)
@@ -63,19 +63,19 b' def split_user_input(line, pattern=None):'
63 63 pattern = line_split
64 64 match = pattern.match(line)
65 65 if not match:
66 # print "match failed for line '%s'" % line
66 # print("match failed for line '%s'" % line)
67 67 try:
68 68 ifun, the_rest = line.split(None,1)
69 69 except ValueError:
70 # print "split failed for line '%s'" % line
70 # print("split failed for line '%s'" % line)
71 71 ifun, the_rest = line, u''
72 72 pre = re.match(r'^(\s*)(.*)',line).groups()[0]
73 73 esc = ""
74 74 else:
75 75 pre, esc, ifun, the_rest = match.groups()
76 76
77 #print 'line:<%s>' % line # dbg
78 #print 'pre <%s> ifun <%s> rest <%s>' % (pre,ifun.strip(),the_rest) # dbg
77 # print('line:<%s>' % line) # dbg
78 # print('pre <%s> ifun <%s> rest <%s>' % (pre,ifun.strip(),the_rest)) # dbg
79 79 return pre, esc or '', ifun.strip(), the_rest.lstrip()
80 80
81 81
@@ -26,7 +26,7 b' else:'
26 26 if name.startswith('C'):
27 27 c = C(name)
28 28
29 #print >> sys.stderr, "ARGV:", sys.argv # dbg
29 # print(>> sys.stderr, "ARGV:", sys.argv) # dbg
30 30
31 31 # This next print statement is NOT debugging, we're making the check on a
32 32 # completely separate process so we verify by capturing stdout:
@@ -43,7 +43,7 b' def mini_interactive_loop(input_func):'
43 43 # Here we just return input so we can use it in a test suite, but a real
44 44 # interpreter would instead send it for execution somewhere.
45 45 src = isp.source_reset()
46 #print 'Input source was:\n', src # dbg
46 # print('Input source was:\n', src) # dbg
47 47 return src
48 48
49 49 #-----------------------------------------------------------------------------
@@ -25,7 +25,7 b' def restore_aliases(ip, alias=None):'
25 25 staliases = ip.db.get('stored_aliases', {})
26 26 if alias is None:
27 27 for k,v in staliases.items():
28 #print "restore alias",k,v # dbg
28 # print("restore alias",k,v) # dbg
29 29 #self.alias_table[k] = v
30 30 ip.alias_manager.define_alias(k,v)
31 31 else:
@@ -43,7 +43,7 b' def refresh_variables(ip):'
43 43 print("Unable to restore variable '%s', ignoring (use %%store -d to forget!)" % justkey)
44 44 print("The error was:", sys.exc_info()[0])
45 45 else:
46 #print "restored",justkey,"=",obj #dbg
46 # print("restored",justkey,"=",obj) # dbg
47 47 ip.user_ns[justkey] = obj
48 48
49 49
@@ -456,13 +456,13 b' class IPythonConsoleLexer(Lexer):'
456 456 # does not use the continuation marker cannot be detected.
457 457 # For example, the 3 in the following is clearly output:
458 458 #
459 # In [1]: print 3
459 # In [1]: print(3)
460 460 # 3
461 461 #
462 462 # But the following second line is part of the input:
463 463 #
464 464 # In [2]: while True:
465 # print True
465 # print(True)
466 466 #
467 467 # In both cases, the 2nd line will be 'output'.
468 468 #
@@ -300,7 +300,7 b' def block_parser(part, rgxin, rgxout, fmtin, fmtout):'
300 300
301 301 nextline = lines[i]
302 302 matchout = rgxout.match(nextline)
303 #print "nextline=%s, continuation=%s, starts=%s"%(nextline, continuation, nextline.startswith(continuation))
303 # print("nextline=%s, continuation=%s, starts=%s"%(nextline, continuation, nextline.startswith(continuation)))
304 304 if matchout or nextline.startswith('#'):
305 305 break
306 306 elif nextline.startswith(continuation):
@@ -538,7 +538,7 b' class EmbeddedSphinxShell(object):'
538 538 # When there is stdout from the input, it also has a '\n' at the
539 539 # tail end, and so this ensures proper spacing as well. E.g.:
540 540 #
541 # In [1]: print x
541 # In [1]: print(x)
542 542 # 5
543 543 #
544 544 # In [2]: x = 5
@@ -699,7 +699,7 b' class EmbeddedSphinxShell(object):'
699 699 """
700 700 self.ensure_pyplot()
701 701 command = 'plt.gcf().savefig("%s")'%image_file
702 #print 'SAVEFIG', command # dbg
702 # print('SAVEFIG', command) # dbg
703 703 self.process_input_line('bookmark ipy_thisdir', store_history=False)
704 704 self.process_input_line('cd -b ipy_savedir', store_history=False)
705 705 self.process_input_line(command, store_history=False)
@@ -270,7 +270,7 b' class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp):'
270 270 if self.subapp is not None:
271 271 # don't bother initializing further, starting subapp
272 272 return
273 # print self.extra_args
273 # print(self.extra_args)
274 274 if self.extra_args and not self.something_to_run:
275 275 self.file_to_run = self.extra_args[0]
276 276 self.init_path()
@@ -127,11 +127,11 b' def inputhook(context):'
127 127 # 0.05 0.5%
128 128 used_time = clock() - t
129 129 if used_time > 10.0:
130 # print 'Sleep for 1 s' # dbg
130 # print('Sleep for 1 s') # dbg
131 131 time.sleep(1.0)
132 132 elif used_time > 0.1:
133 133 # Few GUI events coming in, so we can sleep longer
134 # print 'Sleep for 0.05 s' # dbg
134 # print('Sleep for 0.05 s') # dbg
135 135 time.sleep(0.05)
136 136 else:
137 137 # Many GUI events coming in, so sleep only very little
@@ -53,11 +53,11 b' def inputhook(context):'
53 53 # 0.05 0.5%
54 54 used_time = clock() - t
55 55 if used_time > 10.0:
56 # print 'Sleep for 1 s' # dbg
56 # print('Sleep for 1 s') # dbg
57 57 time.sleep(1.0)
58 58 elif used_time > 0.1:
59 59 # Few GUI events coming in, so we can sleep longer
60 # print 'Sleep for 0.05 s' # dbg
60 # print('Sleep for 0.05 s') # dbg
61 61 time.sleep(0.05)
62 62 else:
63 63 # Many GUI events coming in, so sleep only very little
@@ -137,11 +137,11 b' def inputhook_wx3(context):'
137 137 # 0.05 0.5%
138 138 used_time = clock() - t
139 139 if used_time > 10.0:
140 # print 'Sleep for 1 s' # dbg
140 # print('Sleep for 1 s') # dbg
141 141 time.sleep(1.0)
142 142 elif used_time > 0.1:
143 143 # Few GUI events coming in, so we can sleep longer
144 # print 'Sleep for 0.05 s' # dbg
144 # print('Sleep for 0.05 s') # dbg
145 145 time.sleep(0.05)
146 146 else:
147 147 # Many GUI events coming in, so sleep only very little
@@ -108,7 +108,7 b' class IPython2PythonConverter(object):'
108 108
109 109 newline(line)
110 110 newline('') # ensure a closing newline, needed by doctest
111 #print "PYSRC:", '\n'.join(out) # dbg
111 # print("PYSRC:", '\n'.join(out)) # dbg
112 112 return '\n'.join(out)
113 113
114 114 #return dnew
@@ -68,7 +68,7 b' class IPDoctestOutputChecker(doctest.OutputChecker):'
68 68 ret = doctest.OutputChecker.check_output(self, want, got,
69 69 optionflags)
70 70 if not ret and self.random_re.search(want):
71 #print >> sys.stderr, 'RANDOM OK:',want # dbg
71 # print(>> sys.stderr, 'RANDOM OK:',want) # dbg
72 72 return True
73 73
74 74 return ret
@@ -141,7 +141,7 b' class IPDocTestParser(doctest.DocTestParser):'
141 141 used for error messages.
142 142 """
143 143
144 #print 'Parse string:\n',string # dbg
144 # print('Parse string:\n',string) # dbg
145 145
146 146 string = string.expandtabs()
147 147 # If all lines begin with the same indentation, then strip it.
@@ -245,8 +245,8 b" def ipexec_validate(fname, expected_out, expected_err='',"
245 245 __tracebackhide__ = True
246 246
247 247 out, err = ipexec(fname, options, commands)
248 #print 'OUT', out # dbg
249 #print 'ERR', err # dbg
248 # print('OUT', out) # dbg
249 # print('ERR', err) # dbg
250 250 # If there are any errors, we must check those before stdout, as they may be
251 251 # more informative than simply having an empty stdout.
252 252 if err:
@@ -308,8 +308,8 b' def target_outdated(target,deps):'
308 308 for dep in deps:
309 309 dep_time = os.path.getmtime(dep)
310 310 if dep_time > target_time:
311 #print "For target",target,"Dep failed:",dep # dbg
312 #print "times (dep,tar):",dep_time,target_time # dbg
311 # print("For target",target,"Dep failed:",dep) # dbg
312 # print("times (dep,tar):",dep_time,target_time) # dbg
313 313 return 1
314 314 return 0
315 315
@@ -48,7 +48,7 b' class StrDispatch(object):'
48 48 if re.match(r, key):
49 49 yield obj
50 50 else:
51 #print "nomatch",key # dbg
51 # print("nomatch",key) # dbg
52 52 pass
53 53
54 54 def __repr__(self):
@@ -254,10 +254,10 b' def test_get_xdg_dir_3():'
254 254 def test_filefind():
255 255 """Various tests for filefind"""
256 256 f = tempfile.NamedTemporaryFile()
257 # print 'fname:',f.name
257 # print('fname:',f.name)
258 258 alt_dirs = paths.get_ipython_dir()
259 259 t = path.filefind(f.name, alt_dirs)
260 # print 'found:',t
260 # print('found:',t)
261 261
262 262
263 263 @dec.skip_if_not_win32
@@ -72,8 +72,8 b' class LSString(str):'
72 72
73 73 # def print_lsstring(arg):
74 74 # """ Prettier (non-repr-like) and more informative printer for LSString """
75 # print "LSString (.p, .n, .l, .s available). Value:"
76 # print arg
75 # print("LSString (.p, .n, .l, .s available). Value:")
76 # print(arg)
77 77 #
78 78 #
79 79 # print_lsstring = result_display.register(LSString)(print_lsstring)
@@ -231,7 +231,7 b' class SList(list):'
231 231
232 232 # def print_slist(arg):
233 233 # """ Prettier (non-repr-like) and more informative printer for SList """
234 # print "SList (.p, .n, .l, .s, .grep(), .fields(), sort() available):"
234 # print("SList (.p, .n, .l, .s, .grep(), .fields(), sort() available):")
235 235 # if hasattr(arg, 'hideonce') and arg.hideonce:
236 236 # arg.hideonce = False
237 237 # return
@@ -144,8 +144,8 b' def target_outdated(target,deps):'
144 144 for dep in deps:
145 145 dep_time = os.path.getmtime(dep)
146 146 if dep_time > target_time:
147 #print "For target",target,"Dep failed:",dep # dbg
148 #print "times (dep,tar):",dep_time,target_time # dbg
147 # print("For target",target,"Dep failed:",dep) # dbg
148 # print("times (dep,tar):",dep_time,target_time) # dbg
149 149 return 1
150 150 return 0
151 151
@@ -32,7 +32,7 b''
32 32 " ])\n",
33 33 " while True:\n",
34 34 " inline(code, quiet=True, t=t)\n",
35 " print time.time()\n",
35 " print(time.time())\n",
36 36 " sys.stdout.flush() # this is important\n",
37 37 "\n",
38 38 "gilsleep(5)"
General Comments 0
You need to be logged in to leave comments. Login now