translate txt into HTML

"Martin v. Löwis" martin at
Tue Jan 21 21:51:47 CET 2003

Mike Meyer wrote:
> You've got a bug. Try this for the second print:
> print >>htmlFile, '<body><pre>%s</pre></body></html>' % text.replace('<', '<')

This is a bug only if text contains "<". Likewise, your code has a bug 
if text contains "&".

However, this is precisely the point that Peter was making: The OP 
should really think about the requirements. "translate txt into HTML" 
can be really easy, or can be really difficult, depending on the exact 
requirements. It is very likely that Peter's code is not what the OP 
wants, but everybody has three free guesses what it is that the OP wants.


More information about the Python-list mailing list