problems with opening files due to file's path

Mike Driscoll kyosohma at
Tue Jun 10 21:22:49 CEST 2008

On Jun 10, 2:09 pm, Carsten Haese <carsten.ha... at> wrote:
> Alexnb wrote:
> > No this time it perhaps gave me the worst of all heres what I entered, and
> > the output
> >>>> startfile(r"%s"%full)    ***full is the path***
> > startfile(r"%s"%full)
> > WindowsError: [Error 2] The system cannot find the file specified:
> > '"C:\\Documents and Settings\\Alex\\My Documents\\My
> > Music\\Rhapsody\\Bryanbros\\Jason Mraz\\I\'m Yours (Single)\x01 - I\'m
> > Yours.wma"'
> Contrary to what other posters have asserted, doing the above can't make
> a difference. Putting 'r' in front of a string literal tells Python not
> to give backslashes in the string literal any special treatment. Since
> there are no backslashes in "%s", the 'r' does nothing.

I assumed the OP was trying to do the string substitution within a
path. If the OP is instead doing as you think, then you are quite

> Therefore, (r"%s"%full) is the same as ("%s"%full), which is the same as
> (full), assuming that `full` is the name of a string.
> The real answer lies in fixing the code where you're assigning the
> pathname to 'full', which you haven't posted. Please post the code where
> you're assigning the pathname, or better yet, post the complete code
> you're running.
> --
> Carsten Haese

Sometimes I get too eager to help and don't do enough mental
processing before answering.


More information about the Python-list mailing list