Re: Backslash Escapes

2011-12-26 Thread Lie Ryan
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

Re: Backslash Escapes

2011-12-25 Thread Chris Angelico
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

Re: Backslash Escapes

2011-12-25 Thread Devin Jeanpierre
> 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\

Re: Backslash Escapes

2011-12-25 Thread MRAB
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