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"' Thomas Morton 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) > > -------------------------------------------------- > From: "Alexnb" <[EMAIL PROTECTED]> > Sent: Tuesday, June 10, 2008 7:05 PM > To: <python-list@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 "\\"? >> >> Mike Driscoll wrote: >>> >>> On Jun 10, 11:45 am, Alexnb <[EMAIL PROTECTED]> wrote: >>>> Gerhard Häring wrote: >>>> >>>> > Alexnb wrote: >>>> >> Okay, so what I want my program to do it open a file, a music file >>>> in >>>> >> specific, and for this we will say it is an .mp3. Well, I am using >>>> >> the >>>> >> system() command from the os class. [...] >>>> >>>> >> system("\"C:\Documents and Settings\Alex\My Documents\My >>>> >> Music\Rhapsody\Bryanbros\Weezer\(2001)\04 - Island In The >>>> Sun.wma\"") >>>> >> [...] >>>> >>>> > Try os.startfile() instead. It should work better. >>>> >>>> > -- Gerhard >>>> >>>> > -- >>>> >http://mail.python.org/mailman/listinfo/python-list >>>> >>>> No, it didn't work, but it gave me some interesting feedback when I ran >>>> it >>>> in the shell. Heres what it told me: >>>> >>>> >>> os.startfile("C:\Documents and Settings\Alex\My Documents\My >>>> >>> Music\Rhapsody\Bryanbros\Jason Mraz\I'm Yours (Single)\01 - I'm >>>> >>> Yours.wma") >>>> >>>> Traceback (most recent call last): >>>> File "<pyshell#10>", line 1, in <module> >>>> os.startfile("C:\Documents and Settings\Alex\My Documents\My >>>> Music\Rhapsody\Bryanbros\Jason Mraz\I'm Yours (Single)\01 - I'm >>>> Yours.wma") >>>> >>>> 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" >>>> >>>> See it made each backslash into two, and the one by the parenthesis and >>>> the >>>> 0 turned into an x.... >>>> -- >>>> View this message in >>>> context:http://www.nabble.com/problems-with-opening-files-due-to-file%27s-pat... >>>> Sent from the Python - python-list mailing list archive at Nabble.com. >>> >>> Yeah. You need to either double all the backslashes or make it a raw >>> string by adding an "r" to the beginning, like so: >>> >>> os.startfile(r'C:\path\to\my\file') >>> >>> HTH >>> >>> 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-tp17759531p17761338.html >> Sent from the Python - python-list mailing list archive at Nabble.com. >> >> -- >> http://mail.python.org/mailman/listinfo/python-list > > -- > 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-tp17759531p17761946.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list