[Tutor] Raw string

bob gailer bgailer at gmail.com
Mon Apr 19 00:48:47 CEST 2010

On 4/18/2010 5:49 PM, Neven Goršić wrote:
> Hi!
> When I get file path from 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.

"It doesn't work" is too vague. Please show us a code snippet that 
includes obtaining the file path, attempt to open and what happens. Do 
you get a traceback (error message)? If so, please post it with the code.

Please also reply-all so a copy goes to the list.

> 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

Bob Gailer
Chapel Hill NC

More information about the Tutor mailing list