Escaping HTML
The cgi module that comes with Python has an escape function:
However, it doesn't escape characters beyond &, <, and >.
Here's a small snippet that will let you escape those as well:
Discussion
LionKimbro: Is there anything in the standard library for going the other way? Is there something where you can give it "&" and get back "&"? Perhaps in the XML libraries? I looked, but did not see anything. DOM, SAX- wouldn't be there. Not exactly XML-RPC either. Anyone know? (Answer needed for XML; HTML would be nice as well.) Date(2005-06-10T16:35:16Z)