hello world in L3


Table of Contents

The hello world example: print "hello, world". Only the first execution actually prints output.

1 Say hello

Start the gui via

and paste the code
print "hello world!"
(via the middle mouse button on the canvas) to get

Running this via right button > run code, we get

hello world!
(None, 3)
on the console. (None, 3) is simply the (value, timestamp) returned by print.

2 Second run

Run it again and get only

(None, 3)
Because the print command is unchanged it is not executed again and the old value is returned.

3 Many hellos

When there is more than one world, using

for num in range(5):
    print "hello world %d" % num
is better.

The first run of


hello world 0
hello world 1
hello world 2
hello world 3
hello world 4
(None, 201)

with repeated runs just returning

(None, 201)

4 Many hellos, reused

These values are just the ones we want to use in the greeting template

instead of <value>, so we retrieve them via the menu selection

to get

and insert that list into the template. This is what the new hello looks like:

Running this, we get

['hello world 0', 'hello world 1', 'hello world 2', 'hello world 3', 'hello world 4']
(None, 225)

Running it again just gives the value

(None, 225)


Author: Michael Hohn <mhhohn@users.sourceforge.net>

Date: 2008/04/04 16:36:38