problems with opening files due to file's path

Mike Driscoll kyosohma at gmail.com
Tue Jun 10 15:22:49 EDT 2008


On Jun 10, 2:09 pm, Carsten Haese <carsten.ha... at gmail.com> 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
correct.

>
> 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 Haesehttp://informixdb.sourceforge.net


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

Mike



More information about the Python-list mailing list