problems with opening files due to file's path

Mike Driscoll kyosohma at gmail.com
Tue Jun 10 20:50:29 CEST 2008


On Jun 10, 1:25 pm, "Thomas Morton" <morton.tho... at googlemail.com>
wrote:
> maybe try string substitution... not sure if that's really the BEST way to
> do it but it should work
>
> startfile(r"%s"%variable)


I concur. That should work. A slightly more in depth example (assuming
Windows):

os.startfile(r'C:\Documents and Settings\%s\Desktop\myApp.exe' %
username)

or

os.startfile(r'C:\Program Files\%s' % myApp)

Hopefully this is what you are talking about. If you were referring to
passing in arguments, than you'll want to use the subprocess module
instead.


>
> --------------------------------------------------
> From: "Alexnb" <alexnbr... at gmail.com>
> Sent: Tuesday, June 10, 2008 7:05 PM
> To: <python-l... at python.org>
> Subject: Re: problems with opening files due to file's path
>
>
>
> > Well, now i've hit another problem, this time being that the path will be
> > a
> > variable, and I can't figure out how to make startfile() make it raw with
> > a
> > variable, if I put startfile(r variable), it doesn't work and
> > startfile(rvariable) obviously won't work, do you know how to make that
> > work
> > or better yet, how to take a regular string that is given and make every
> > single "\" into a double "\\"?
>

<snip>

Mike



More information about the Python-list mailing list