Next / Previous / Contents / TCC Help System / NM Tech homepage

5. Code prologue

The implementation of tccpage2.py is included here in “literate programming” style. For information on the tool used for code generation, see A source extractor for lightweight literate programming.

The actual code starts with the conventional Python documentation string:

tccpage2.py
"""tccpage2.py: For dynamic generaton of web pages in standard TCC style.

    For documentation, see:
        http://www.nmt.edu/tcc/projects/tccpage/
"""

Next, some imports. We need the sys module so we can use sys.stdout as the default output file. We need the time module for timestamping the page.

tccpage2.py
#================================================================
# Imports
#----------------------------------------------------------------

import sys
import time

Also, we'll need to import the xmlcreate.py module discussed in Python XML processing with lxml.

tccpage2.py
from lxml import etree as et