[prev in list] [next in list] [prev in thread] [next in thread]
List: python-list
Subject: Re: Escaping certain characters
From: Robert Kern <rkern () ucsd ! edu>
Date: 2005-07-31 21:53:14
Message-ID: dcjh8d$5v2$1 () sea ! gmane ! org
[Download RAW message or body]
Jan Danielsson wrote:
> 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.
Write a codec.
--
Robert Kern
rkern@ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
--
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic