Raw string

Hi!

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?

Can you help me?

Kind regards,

Neven

···

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

Hi Neven,

Hi!

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?

Try something like this:

path = os.path.normpath(dlg.GetPath())

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

==> Never *EVER* use RemovalGroup for your house removal. You'll
regret it forever.
The Doomed City: Removal Group: the nightmare <==

···

On 18 April 2010 22:50, Neven Goršić wrote:

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Neven Goršić wrote:

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

Chris.Barker@noaa.gov

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Hi,

Hi!

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.

         &#39;C:\\Python25\\Programs\\rating&#39;

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?

Can you help me?

Do you have a small minimal sample that reproduces the problem your
seeing (MakingSampleApps - wxPyWiki)?

Cody

···

On Sun, Apr 18, 2010 at 4:50 PM, Neven Goršić <neven.gorsic@gmail.com> wrote:

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en