5.3.1. Long script sections

You can code long script sections such as a class definition. The rule is: a long script section is started by a line starting with @ and ending with :,( or one of the characters that python would recognize that signifies that there is more to come. You must then indent the code with exactly one extra space. A long script section is ended by the first line not having a space character in column 1 (or the end of file).

The whole of a long script section is collected and then executed at once. On-the-fly interscript for test 8 follows.

Start interscript section from tutorial.pak
   385: @head(1,'Long script sections')
   386: Here is a long script. We define a class MyClass.
   387: @class MyClass:
   388:    def __init__(self, name):
   389:      self.name = name
   390:    def hello(self):
   391:      print 'Hello',self.name
   393:  # test it
   394:  me = MyClass('John')
   395:  me.hello()
   396:  deliberate error
   397: @doc()
   398: After all that, the deliberate error is ignored.
End interscript section from tutorial.pak
Test output at ../tests/output/test_8.html. Logfile at ../tests/output/test_8.log.

Errors in script sections are reported with a traceback to the logfile, but do not halt processing. You cannot terminate an Interscript processing run inside a script section, not even with sys.exit(). [Interscript can be terminated with a keyboard interrupt or system abort signal, however.]