using app engine - yes i know all about django templates and other template engines.
Lets say i have a dictionary or a simple object, i dont know its structure and i
import pprint
pprint.pprint(yourDict)
Well, no HTML, but similar to your for/print
approach.
EDIT: or use:
niceText = pprint.pformat(yourDict)
this will give you the same nice output with all indents, etc. Now you can iterate over lines and format it into HTML:
htmlLines = []
for textLine in pprint.pformat(yourDict).splitlines():
htmlLines.append('
%s' % textLine) # or something even nicer
htmlText = '\n'.join(htmlLines)