Backslash Escapes

Lie Ryan lie.1296 at gmail.com
Mon Dec 26 04:36:39 EST 2011


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 data on the 
interactive shell since the interactive shell uses __repr__ by default.

> 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 now goes like this:

You shouldn't ever need to unless your file are backslash-escaped.




More information about the Python-list mailing list