more on unescaping escapes
mwilson at the-wire.com
Tue Feb 24 02:03:28 CET 2009
> Not sure if it's more clear or not :)
> >>> a="c:\\Program\x20Files\\test"
> >>> a
> 'c:\\Program Files\\test'
> >>> print a
> c:\Program Files\test
> Which is all fine. And I didn't need to use decode().
> So, in this case I'm assuming that the interpreter is converting the
> escapes on assignment. And, in this case the string has single \s in it.
Strictly speaking, the compiler is converting the escapes when it uses the
literal to create a string value.
More information about the Python-list