more on unescaping escapes

Tim Wintle tim.wintle at
Tue Feb 24 01:13:06 CET 2009

On Mon, 2009-02-23 at 17:00 -0700, bvdp wrote:
> Let's see if this makes sense:
>  >>> a='c:\\Program Files\\test'
>  >>> a.decode('string-escape')
> 'c:\\Program Files\test'

Hint: try running

>>> print a

and see what's written - I think that the interpreter adds extra "\"
characters to escape things and make things more easy to read.


>>> a = "c:\\test\\t"
>>> a
>>> print a

so when it displays strings in the interpreter it includes escape
characters, when it is printed though the output is straight to stdout
and isn't escaped.

Hope that helps,

Tim Wintle

More information about the Python-list mailing list