i have a but string might contain \", what should I do to escape it?
Example:
__string__ = t
If your value being escaped might contain quotes, the best thing is to use the quoteattr method: http://docs.python.org/library/xml.sax.utils.html#module-xml.sax.saxutils
quoteattr
This is referenced right beneath the docs on the cgi.escape() method.