open file with whitespaces

Claudio Grondi claudio.grondi at freenet.de
Fri May 19 10:42:50 EDT 2006


Christophe wrote:
> mardif a écrit :
> 
>> Hi guys.
>> I've a very big big big problem:
>>
>> I've in my windows computer a file named cicciobello.html, located in
>> c:\documents and settings\username\desktop\cicciobello.html.
>>
>> Now, I MUST open this file with os.spawn(os.P_WAIT ...., because I must
>> wait the user cancel the explorer window, ok?
>> And so, I write:
>>
>> import os
>> os.spawnl(os.P_WAIT, "c:\programmi\internet explorer\iexplorer.exe",
>> "c:\documents and settings\username\desktop\cicciobello.html")
>>
>> the python process don't fail, but explorer don't visualize correctly
>> the file opened: i receive an "not found" error message.
>>
>> I've found that the whitespaces in file path are the problem.
>> If you see to explorer address bar, you will find the address
>> completely wrong...
>>
>> I've found no solution!
>> Can you help me, please??
>>
>> thx very very very much!!!
>>
> 
> And I thought the problem where the incorrectly used \ :) Try that first :
> 
> os.spawnl(os.P_WAIT, r"c:\programmi\internet explorer\iexplorer.exe",
> r"c:\documents and settings\username\desktop\cicciobello.html")
Another option to try in case this is not the problem is to put the file 
name in quotation marks as it is necessary when using command line shell 
(not  tested, just an idea):

os.spawnl(os.P_WAIT,'"c:\\programmi\\internet explorer\\iexplorer.exe"',
  '"c:\\documents and settings\\username\\desktop\\cicciobello.html"')



More information about the Python-list mailing list