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
   349: @head(1,'Long script sections')
   350: Here is a long script. We define a class MyClass.
   351: @class MyClass:
   352:    def __init__(self, name):
   353:      self.name = name
   354:    def hello(self):
   355:      print 'Hello',self.name
   356: 
   357:  # test it
   358:  me = MyClass('John')
   359:  me.hello()
   360:  deliberate error
   361: @doc()
   362: 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.]