On 12/26/2011 12:04 PM, Felipe O wrote:
Hi all,
Whenever I take any input (raw_input, of course!) or I read from a
file, etc., any backslashes get escaped automatically.
Python never escapes backslashes when reading from raw_input or files.
Python only ever escapes backslashes when displaying
On Mon, Dec 26, 2011 at 12:04 PM, Felipe O wrote:
> Hi all,
> Whenever I take any input (raw_input, of course!) or I read from a
> file, etc., any backslashes get escaped automatically. Is there any
> elegant way of parsing the backslashes as though they were written in
> a python string... I gues
> Whenever I take any input (raw_input, of course!) or I read from a
> file, etc., any backslashes get escaped automatically.
They don't get escaped, they get... treated as the bytes that they
are. If you want them to mean what they do in Python, use the
'string_escape' codec.
>>> x = r'nyan\
On 26/12/2011 01:04, Felipe O wrote:
Hi all,
Whenever I take any input (raw_input, of course!) or I read from a
file, etc., any backslashes get escaped automatically. Is there any
elegant way of parsing the backslashes as though they were written in
a python string. The best I have so far right n