problems with opening files due to file's path

Alexnb alexnbryan at gmail.com
Tue Jun 10 20:57:48 CEST 2008


That would work, but not for what I want. See the file could be anywhere on
the user's system and so the entire path will be unique, and that didn't
work with a unique path. What is the subprocess module you are talking
about?

Mike Driscoll wrote:
> 
> 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
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
> 

-- 
View this message in context: http://www.nabble.com/problems-with-opening-files-due-to-file%27s-path-tp17759531p17762276.html
Sent from the Python - python-list mailing list archive at Nabble.com.




More information about the Python-list mailing list