def ToHTMLList(thing): try: lines = itertools.imap(ToHTMLList, thing) return '%s' % ''.join(lines) except TypeError: return str(thing)