Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: problems with opening files due to file's path

Reply
Thread Tools

Re: problems with opening files due to file's path

 
 
Alexnb
Guest
Posts: n/a
 
      06-10-2008



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-...p17759825.html
Sent from the Python - python-list mailing list archive at Nabble.com.

 
Reply With Quote
 
 
 
 
Mike Driscoll
Guest
Posts: n/a
 
      06-10-2008
On Jun 10, 11:45*am, Alexnb <(E-Mail Removed)> wrote:
> Gerhard Hring 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-...o-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
 
Reply With Quote
 
 
 
 
Alexnb
Guest
Posts: n/a
 
      06-10-2008

Hey thanks!, both the raw and the double backslashes worked. You are a
gentleman and a scholar.

Mike Driscoll wrote:
>
> On Jun 10, 11:45 am, Alexnb <(E-Mail Removed)> 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-...o-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-...p17761126.html
Sent from the Python - python-list mailing list archive at Nabble.com.

 
Reply With Quote
 
Alexnb
Guest
Posts: n/a
 
      06-10-2008

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 <(E-Mail Removed)> 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-...o-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-...p17761338.html
Sent from the Python - python-list mailing list archive at Nabble.com.

 
Reply With Quote
 
Thomas Morton
Guest
Posts: n/a
 
      06-10-2008
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" <(E-Mail Removed)>
Sent: Tuesday, June 10, 2008 7:05 PM
To: <(E-Mail Removed)>
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 <(E-Mail Removed)> 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-...o-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-...p17761338.html
> Sent from the Python - python-list mailing list archive at Nabble.com.
>
> --
> http://mail.python.org/mailman/listinfo/python-list


 
Reply With Quote
 
Alexnb
Guest
Posts: n/a
 
      06-10-2008

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" <(E-Mail Removed)>
> Sent: Tuesday, June 10, 2008 7:05 PM
> To: <(E-Mail Removed)>
> 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 <(E-Mail Removed)> 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-...o-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-...p17761338.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-...p17761946.html
Sent from the Python - python-list mailing list archive at Nabble.com.

 
Reply With Quote
 
Mike Driscoll
Guest
Posts: n/a
 
      06-10-2008
On Jun 10, 1:25*pm, "Thomas Morton" <(E-Mail Removed)>
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" <(E-Mail Removed)>
> Sent: Tuesday, June 10, 2008 7:05 PM
> To: <(E-Mail Removed)>
> 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
 
Reply With Quote
 
Alexnb
Guest
Posts: n/a
 
      06-10-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" <(E-Mail Removed)>
> 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" <(E-Mail Removed)>
>> Sent: Tuesday, June 10, 2008 7:05 PM
>> To: <(E-Mail Removed)>
>> 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-...p17762276.html
Sent from the Python - python-list mailing list archive at Nabble.com.

 
Reply With Quote
 
Thomas Morton
Guest
Posts: n/a
 
      06-10-2008
heh thanks Mike - glad im not going mad

Just tested locally in IDLE (I know I know!) and it works for me like this:

>>> test = os.path.join(os.getcwd(),"NEWS.txt")
>>> test

'D:\\Python25\\NEWS.txt'
>>> os.startfile(r"%s"%test)
>>>


And the file opens...

Does the file definitely exist?

Tom
--------------------------------------------------
From: "Alexnb" <(E-Mail Removed)>
Sent: Tuesday, June 10, 2008 7:37 PM
To: <(E-Mail Removed)>
Subject: Re: problems with opening files due to file's path

>
> 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" <(E-Mail Removed)>
>> Sent: Tuesday, June 10, 2008 7:05 PM
>> To: <(E-Mail Removed)>
>> 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 <(E-Mail Removed)> 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-...o-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-...p17761338.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-...p17761946.html
> Sent from the Python - python-list mailing list archive at Nabble.com.
>
> --
> http://mail.python.org/mailman/listinfo/python-list


 
Reply With Quote
 
Carsten Haese
Guest
Posts: n/a
 
      06-10-2008
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.

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
http://informixdb.sourceforge.net
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
os.path.walk() to get full path of all files dude Python 5 03-17-2011 09:09 AM
Fixing Ant build that fails due to space in path eran Java 6 08-08-2008 08:43 PM
problems with opening files due to file's path Alexnb Python 0 06-10-2008 04:28 PM
How to due with "warning LNK4075: ignoring '/INCREMENTAL' due to Fresh C++ 2 04-22-2008 09:03 PM
Kodak EasyShare can't find photos due to bad path Doug Clemens Digital Photography 3 01-12-2004 05:35 PM



Advertisments