for loops to dynamically generate part of the HTML that is sent to the browser. Spe-
cifically, it emits HTML to lay out a two-dimensional table in the middle of a page, as
shown in Figure 15-5.
Figure 15-5. A page with a table generated by tutor2.py
Each row in the table displays a “row.column” pair, as generated by the executing
Python script. If you’re curious how the generated HTML looks, select your browser’s
View Source option after you’ve accessed this page. It’s a single HTML page composed
of the HTML generated by the first print in the script, then the for loops, and finally
the last print. In other words, the concatenation of this script’s output is an HTML
document with headers.
Table tags
The script in Example 15-5 generates HTML table tags. Again, we’re not out to learn
HTML here, but we’ll take a quick look just so that you can make sense of this book’s
examples. Tables are declared by the text between
Typically, a table’s text in turn declares the contents of each table row between
and
in our script build up HTML to declare five rows of four columns each by printing the
appropriate tags, with the current row and column number as column values.
For instance, here is part of the script’s output, defining the first two rows (to see the
full output, run the script standalone from a system command line, or select your
browser’s View Source option):
1148 | Chapter 15: Server-Side Scripting