When I get file path from wx.DirDialog, I get in a (path) variable.
Sometimes that string (path) contains special escape sequences, such as \x, \r and so on.
'C:\Python25\Programs\rating'
When I try to open that file (whose name contains escape sequences) it doesn’t work.
I know that raw string marker ‘r’ in front of string leaves char ‘’ as character and not as start of escape sequences,
but I can not apply it to a variable name which contains file path.
Is
there a function with same effect as raw string marker, as my problem must be solved differently?
When I get file path from wx.DirDialog, I get in a (path) variable.
Sometimes that string (path) contains special escape sequences, such as \x,
\r and so on.
'C:\\Python25\\Programs\\rating'
When I try to open that file (whose name contains escape sequences) it
doesn't work.
I know that raw string marker 'r' in front of string leaves char '\' as
character and not as start of escape sequences,
but I can not apply it to a variable name which contains file path.
Is there a function with same effect as raw string marker, as my problem
must be solved differently?
When I get file path from wx.DirDialog, I get in a (path) variable.
Sometimes that string (path) contains special escape sequences, such as \x, \r and so on.
that may be a unicode string...
'C:\Python25\Programs\rating'
where there special characters here? the "\" is the standard Windows path separator. Was that your actual example that failed? it sure should work, unless that path doesn't exist, or there is a permission issue or something.
When I try to open that file (whose name contains escape sequences) it doesn't work.
it should -- that is odd.
I know that raw string marker 'r' in front of string leaves char '\' as character and not as start of escape sequences,
that applies only to string literals - putting them in your code -- a string can hold any sequence of bytes the "\" is not special once it's a string (or unicode) object.
-Chris
···
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
When I get file path from wx.DirDialog, I get in a (path) variable.
Sometimes that string (path) contains special escape sequences, such as \x,
\r and so on.
'C:\\Python25\\Programs\\rating'
Your seeing this in a 'print' statement right? The strings actual
value will be 'C:\\Python25\\Programs\\rating'. When it is printed the
escaped '\\' get transformed to the display value '\'.
When I try to open that file (whose name contains escape sequences) it
doesn't work.
How are you trying to open the file?
I know that raw string marker 'r' in front of string leaves char '\' as
character and not as start of escape sequences,
but I can not apply it to a variable name which contains file path.
Is there a function with same effect as raw string marker, as my problem
must be solved differently?