r"<path>"

Carsten Haese carsten.haese at gmail.com
Tue Sep 30 19:55:15 CEST 2008


Kyle Hayes wrote:
>> Please describe the actual problem you're trying to solve. In what way
>> do slashes need to be "fixed," and why?
> 
> Well, I have decided to build a tool to help us sync files in UNC
> paths. I am just building the modules and classes right now so I
> haven't developed the frontend yet. I am assuming when the user
> provides a path (either by typing it in, or pulling it in from a
> config file), the UNC slashes are going to escape stuff in the string,
> so I want to double them up.

That assumption is incorrect. While backslashes in string literals are
escape characters that must be doubled up to convey literal backslashes,
no such interpretation is made for backslashes that are read from a GUI
text box or from a file.

See for yourself:
>>> some_string = raw_input("Enter a string: ")
Enter a string: blah\blah\blah
>>> print some_string
blah\blah\blah

Carry on and come back when you actually have a problem ;)

--
Carsten Haese
http://informixdb.sourceforge.net



More information about the Python-list mailing list