11"""Implementation of code management magic functions.
22"""
3+ from __future__ import print_function
34#-----------------------------------------------------------------------------
45# Copyright (c) 2012 The IPython Development Team.
56#
@@ -189,15 +190,15 @@ def save(self, parameter_s=''):
189190 try :
190191 overwrite = self .shell .ask_yes_no ('File `%s` exists. Overwrite (y/[N])? ' % fname , default = 'n' )
191192 except StdinNotImplementedError :
192- print "File `%s` exists. Use `%%save -f %s` to force overwrite" % (fname , parameter_s )
193+ print ( "File `%s` exists. Use `%%save -f %s` to force overwrite" % (fname , parameter_s ) )
193194 return
194195 if not overwrite :
195- print 'Operation cancelled.'
196+ print ( 'Operation cancelled.' )
196197 return
197198 try :
198199 cmds = self .shell .find_user_code (codefrom ,raw )
199200 except (TypeError , ValueError ) as e :
200- print e .args [0 ]
201+ print ( e .args [0 ])
201202 return
202203 out = py3compat .cast_unicode (cmds )
203204 with io .open (fname , mode , encoding = "utf-8" ) as f :
@@ -207,8 +208,8 @@ def save(self, parameter_s=''):
207208 # make sure we end on a newline
208209 if not out .endswith (u'\n ' ):
209210 f .write (u'\n ' )
210- print 'The following commands were written to file `%s`:' % fname
211- print cmds
211+ print ( 'The following commands were written to file `%s`:' % fname )
212+ print ( cmds )
212213
213214 @line_magic
214215 def pastebin (self , parameter_s = '' ):
@@ -230,7 +231,7 @@ def pastebin(self, parameter_s=''):
230231 try :
231232 code = self .shell .find_user_code (args )
232233 except (ValueError , TypeError ) as e :
233- print e .args [0 ]
234+ print ( e .args [0 ])
234235 return
235236
236237 from urllib2 import urlopen # Deferred import
@@ -337,7 +338,7 @@ def load(self, arg_s):
337338 ans = True
338339
339340 if ans is False :
340- print 'Operation cancelled.'
341+ print ( 'Operation cancelled.' )
341342 return
342343
343344 self .shell .set_next_input (contents )
@@ -459,7 +460,7 @@ class DataIsObject(Exception): pass
459460
460461 if use_temp :
461462 filename = shell .mktempfile (data )
462- print 'IPython will make a temporary file named:' ,filename
463+ print ( 'IPython will make a temporary file named:' ,filename )
463464
464465 # use last_call to remember the state of the previous call, but don't
465466 # let it be clobbered by successive '-p' calls.
@@ -637,7 +638,7 @@ def edit(self, parameter_s='',last_call=['','']):
637638 self ._edit_macro (args , e .args [0 ])
638639 return
639640 except InteractivelyDefined as e :
640- print "Editing In[%i]" % e .index
641+ print ( "Editing In[%i]" % e .index )
641642 args = str (e .index )
642643 filename , lineno , is_temp = self ._find_edit_target (self .shell ,
643644 args , opts , last_call )
@@ -647,7 +648,7 @@ def edit(self, parameter_s='',last_call=['','']):
647648 return
648649
649650 # do actual editing here
650- print 'Editing...' ,
651+ print ( 'Editing...' , end = ' ' )
651652 sys .stdout .flush ()
652653 try :
653654 # Quote filenames that may have spaces in them
@@ -665,9 +666,9 @@ def edit(self, parameter_s='',last_call=['','']):
665666 self .shell .user_ns ['pasted_block' ] = f .read ()
666667
667668 if 'x' in opts : # -x prevents actual execution
668- print
669+ print ()
669670 else :
670- print 'done. Executing edited code...'
671+ print ( 'done. Executing edited code...' )
671672 with preserve_keys (self .shell .user_ns , '__file__' ):
672673 if not is_temp :
673674 self .shell .user_ns ['__file__' ] = filename
0 commit comments