From 2ddc5510642672bc8c8d3cff747354c4d70b336b 2005-10-08 08:00:20 From: fperez Date: 2005-10-08 08:00:20 Subject: [PATCH] Added demo example to SVN --- diff --git a/doc/examples/example-demo.py b/doc/examples/example-demo.py new file mode 100644 index 0000000..9128018 --- /dev/null +++ b/doc/examples/example-demo.py @@ -0,0 +1,40 @@ +"""A simple interactive demo to illustrate the use of IPython's Demo class. + +Any python script can be run as a demo, but that does little more than showing +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. +""" + +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. +# Note that in actual interactive execution, +# --- stop --- + +x = 1 +y = 2 + +# --- stop --- + +# the mark below makes this block as silent +# silent + +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.' +z = x+y + +print 'z=',x + +# --- stop --- +# This is just another normal block. +print 'z is now:', z + +print 'bye!'