From: Kevin A. <al...@se...> - 2001-08-23 20:04:43
|
> The problem I have is a generic Python problem that I need an answer to in > order to finish the method. I'm adding string attributes like so: > dStr += " '%s':'%s', \n" % (key, value) > This doesn't escape the string, so if you have a single quote, > newline, tab, > etc. in the string then the output isn't going to be correct. I thought > there was a general string escape method, but I'm not finding it. I can > write my own to parse the string and put in \n \t \xhh for hex... > but there > has to be a routine that already does this for me in the standard > libraries. > Pointers please. Doh. I shouldn't ever write documentation and code on the same day, writing docs apparently makes me dumb. repr() seems to do the job, though I didn't test all the special characters. ka |