Introduction

O
utput objects stand as an interface between the code that generates the content for the site and the raw HTML that gets sent back to the browser. I hate seeing code like this:
  print "<table>"
  print "<tr>"
  print "<td>foo</td>"
  print "<td>bar</td>"
  etc.
because it's very difficult to ensure proper balancing of tags, and thus very easy to generate incorrect HTML (the kind that some browsers render correctly and others don't).

Output objects provide a way to build an entire page dynamically, before sending a single line of output to the browser. This has several advantages. First, if at the last minute the script discovers an error, it can throw out the nearly-complete page and produce a new page which notes the error condition. Second, the page need not be constructed from the top to the bottom, but can be built piecemeal as the script gathers and processes information.