Debian Codegraph @

examples/IPython Kernel/example-demo.py

raw
1 # -*- coding: utf-8 -*-
2 """A simple interactive demo to illustrate the use of IPython's Demo class.
3
4 Any python script can be run as a demo, but that does little more than showing
5 it on-screen, syntax-highlighted in one shot. If you add a little simple
6 markup, you can stop at specified intervals and return to the ipython prompt,
7 resuming execution later.
8
9 This is a unicode test, åäö
10 """
11
12 print('Hello, welcome to an interactive IPython demo.')
13 print('Executing this block should require confirmation before proceeding,')
14 print('unless auto_all has been set to true in the demo object')
15
16 # The mark below defines a block boundary, which is a point where IPython will
17 # stop execution and return to the interactive prompt.
18 # <demo> --- stop ---
19
20 x = 1
21 y = 2
22
23 # <demo> --- stop ---
24
25 # the mark below makes this block as silent
26 # <demo> silent
27
28 print('This is a silent block, which gets executed but not printed.')
29
30 # <demo> --- stop ---
31 # <demo> auto
32 print('This is an automatic block.')
33 print('It is executed without asking for confirmation, but printed.')
34 z = x+y
35
36 print('z=',x)
37
38 # <demo> --- stop ---
39 # This is just another normal block.
40 print('z is now:', z)
41
42 print('bye!')