more on unescaping escapes

bvdp bob at mellowood.ca
Mon Feb 23 17:05:42 EST 2009


So, we think something is working and send of a bug fix to our client :)

I'm not sure I understand this at all and wonder if there is bug?

 >>> a="c:\\Program\x20Files\\test"
 >>> a
'c:\\Program Files\\test'

so far, so good.

 >>> a.decode("string-escape")
'c:\\Program Files\test'

Umm, not so good? The \\ before the P is okay, but the \\t is change to \t

and

 >>> print a.decode("string-escape")
c:\Program Files        est

Now, decode() converted the \\t to a \t and print expanded the \t to a tab.

I would have thought that the \\t would have the same result as the \\P ???

Obviously my brain is missing something (hopefully obvious).




More information about the Python-list mailing list