#!/usr/bin/env python # coding: utf-8 from string import Template from substable import rows template = open('template.html').read().decode("utf-8") template = Template(template) def make_row(things): row = [u""] for thing in things: row.append("%s" % thing) row.append(u"") return '\n'.join(row) htrows = [] for row in rows: htrows.append(make_row(row)) htrows = '\n'.join(htrows) print htrows[0] exit() d = { u'rows': htrows, u'title': u'a title', u'css': u'style.css' } page = template.substitute(d) print page