From 48b9481970f28322f5f14889256aa2707fcbcaaa 2012-04-14 20:14:47 From: Thomas Kluyver Date: 2012-04-14 20:14:47 Subject: [PATCH] Make print syntax in GUI integration examples Python 3 compatible. --- diff --git a/docs/examples/lib/example-demo.py b/docs/examples/lib/example-demo.py index 9128018..4b34a36 100644 --- a/docs/examples/lib/example-demo.py +++ b/docs/examples/lib/example-demo.py @@ -5,10 +5,11 @@ it on-screen, syntax-highlighted in one shot. If you add a little simple markup, you can stop at specified intervals and return to the ipython prompt, resuming execution later. """ +from __future__ import print_function -print 'Hello, welcome to an interactive IPython demo.' -print 'Executing this block should require confirmation before proceeding,' -print 'unless auto_all has been set to true in the demo object' +print('Hello, welcome to an interactive IPython demo.') +print('Executing this block should require confirmation before proceeding,') +print('unless auto_all has been set to true in the demo object') # The mark below defines a block boundary, which is a point where IPython will # stop execution and return to the interactive prompt. @@ -23,18 +24,18 @@ y = 2 # the mark below makes this block as silent # silent -print 'This is a silent block, which gets executed but not printed.' +print('This is a silent block, which gets executed but not printed.') # --- stop --- # auto -print 'This is an automatic block.' -print 'It is executed without asking for confirmation, but printed.' +print('This is an automatic block.') +print('It is executed without asking for confirmation, but printed.') z = x+y -print 'z=',x +print('z=',x) # --- stop --- # This is just another normal block. -print 'z is now:', z +print('z is now:', z) -print 'bye!' +print('bye!') diff --git a/docs/examples/lib/gui-gtk.py b/docs/examples/lib/gui-gtk.py index 2a9c2cb..64d364f 100755 --- a/docs/examples/lib/gui-gtk.py +++ b/docs/examples/lib/gui-gtk.py @@ -14,7 +14,7 @@ import gtk def hello_world(wigdet, data=None): - print "Hello World" + print("Hello World") def delete_event(widget, event, data=None): return False diff --git a/docs/examples/lib/gui-tk.py b/docs/examples/lib/gui-tk.py index 6fbe2f3..beb8677 100755 --- a/docs/examples/lib/gui-tk.py +++ b/docs/examples/lib/gui-tk.py @@ -20,7 +20,7 @@ class MyApp: self.button.pack(side=LEFT) def hello_world(self): - print "Hello World!" + print("Hello World!") root = Tk() diff --git a/docs/examples/lib/gui-wx.py b/docs/examples/lib/gui-wx.py index d2db14e..2ed4a27 100755 --- a/docs/examples/lib/gui-wx.py +++ b/docs/examples/lib/gui-wx.py @@ -69,12 +69,12 @@ class MyFrame(wx.Frame): def OnTimeToClose(self, evt): """Event handler for the button click.""" - print "See ya later!" + print("See ya later!") self.Close() def OnFunButton(self, evt): """Event handler for the button click.""" - print "Having fun yet?" + print("Having fun yet?") class MyApp(wx.App): @@ -82,7 +82,7 @@ class MyApp(wx.App): frame = MyFrame(None, "Simple wxPython App") self.SetTopWindow(frame) - print "Print statements go to this stdout window by default." + print("Print statements go to this stdout window by default.") frame.Show(True) return True @@ -96,7 +96,7 @@ if __name__ == '__main__': else: frame = MyFrame(None, "Simple wxPython App") app.SetTopWindow(frame) - print "Print statements go to this stdout window by default." + print("Print statements go to this stdout window by default.") frame.Show(True) try: diff --git a/docs/examples/lib/internal_ipkernel.py b/docs/examples/lib/internal_ipkernel.py index 843348b..afdb065 100644 --- a/docs/examples/lib/internal_ipkernel.py +++ b/docs/examples/lib/internal_ipkernel.py @@ -41,10 +41,10 @@ class InternalIPKernel(object): #self.namespace['ipkernel'] = self.ipkernel # dbg def print_namespace(self, evt=None): - print "\n***Variables in User namespace***" + print("\n***Variables in User namespace***") for k, v in self.namespace.iteritems(): if k not in self._init_keys and not k.startswith('_'): - print '%s -> %r' % (k, v) + print('%s -> %r' % (k, v)) sys.stdout.flush() def new_qt_console(self, evt=None): diff --git a/docs/examples/lib/ipkernel_wxapp.py b/docs/examples/lib/ipkernel_wxapp.py index 549a5ca..a85de7b 100755 --- a/docs/examples/lib/ipkernel_wxapp.py +++ b/docs/examples/lib/ipkernel_wxapp.py @@ -90,7 +90,7 @@ class MyFrame(wx.Frame, InternalIPKernel): def OnTimeToClose(self, evt): """Event handler for the button click.""" - print "See ya later!" + print("See ya later!") sys.stdout.flush() self.cleanup_consoles(evt) self.Close()