Smith, Jeff wrote: > 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:
You might want to consider some kind of template library; there are many to choose from. Generally speaking they merge a template and a data model. You would have a common data model and two templates - one for HTML and one for plain text. There are many Python template libraries to choose from; a relatively simple one is in this recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/162292 Many more are listed here in the Templating Engines section: http://wiki.python.org/moin/WebProgramming Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor