Re: Escaping certain characters
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: Escaping certain characters

From: Jan Danielsson <jan.danielsson@gmail.com>
Date: Sun Jul 31 2005 - 23:46:09 CEST

Robert Kern wrote:
[---]
>> Hmm... On second thought, I need to escape more characters.
>>
>> Is there no other way to escape characters in strings?
>
> Which characters?

   I need to escape '\n', '"', '[' and ']'. I finally went with a few of
these:
string.replace('\n', '\\n')
string.replace('"', '\\"')
...

   I assume that's good enough, but I somehow expected there to exist
some form of "insert your conversion table here" built-in string escaper.
Received on Thu Sep 29 17:18:03 2005