[Tutor] HTML/text formatting question

Smith, Jeff jsmith at medplus.com
Wed Aug 3 17:29:41 CEST 2005

I have a tool that outputs data in either html or text output.

Currently I'm writing chucks like:

if html:    
    print '<html><body bgcolor="FFFFCC">'
    print '<table border="1" bgcolor="CCCCFF" width="800">'
    print '<tr><td colspan="2"><h2>'
print 'Differences %s: %s' % (htypestr, lbl1)
if html:

This seems clunky and my next step was going to be to define generic
functions which would generate the surrounding html tags only when
passed the proper argument.  I was wondering if there was a better way
to do this with a standard Python library.  It looked like formatter
might but that it also might be too low-level.

Any help is appreciated,

More information about the Tutor mailing list