Re: r"<path>"



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
.



Relevant Pages

  • Re: DATABASE field table format - changes not saved over Citrix
    ... the forward slashes were typos. ... The switches do work, but certain changes to ... It must be a Citrix ... >require BACKslashes, not forward slashes, as in your ...
    (microsoft.public.word.mailmerge.fields)
  • Re: Thanks for help re: %userprofile%
    ... Python likes forward slashes in file names, whereas windows likes back ... The string does NOT actually contain any doubled backslashes. ...
    (comp.lang.python)
  • Re: Accessing my home web page... Help!
    ... > backslashes in an URL to slashes automatically before sending the ... So, never use backslashes instead ... > that defines the HTTP protocol and RFC 2396 that tells how URLs ... backslash characters, and treats them as non-special characters ...
    (comp.programming)
  • Re: Works on my computer, not on my site
    ... > Thanks, I think all the folder/pointer issues are okay, but I'll double ... A URL does *NOT* use backslashes!! ... URLs use FORWARD slashes. ... When I manually change the backslashes to forward slashes I am able to ...
    (alt.html)
  • Re: How to delete this file ???
    ... > Really sorry for long time between me letters. ... Note that it's almost always better to use forward slashes instead. ... (An unfortunate additional area is that os.path for Windows normalizes ... things to use backslashes, and therefore path comparisons can get a little ...
    (comp.lang.python)