Spaces in path name
davids at evertech.com.au
Sat Mar 15 01:15:47 CET 2008
By mapping network drives in windows I can get past these issues with path
"Tim Golden" <mail at timgolden.me.uk> wrote in message
news:mailman.1949.1205496184.9267.python-list at python.org...
> David S wrote:
>> Gets me further but still seems to be issue with space after 'Program' as
>> code tries to run 'C:\Program'. Don't understand what is going on here...
> Slight apologies as I haven't followed this thread closely, but using the
> Acrobat Reader executable, which is, I think, good enough for the
> purposes of illustration:
> import os
> import subprocess
> filename = r"C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe"
> doc = r"C:\Program Files\Adobe\Reader 8.0\Resource\ENUtxt.pdf"
> print os.path.isfile (filename)
> os.system (filename + " " + doc)
> os.system ('"%s" "%s"' % (filename, doc))
> subprocess.call ([filename, doc])
> os.path.isfile succeeds
> os.system (filename) fails as your code does
> os.system ('"%s"' ...) fails even though both strings are requoted
> subprocess.call (filename) succeeds
> The latter, at least, is because the subprocess module
> has some special-case handling for exactly this situation
> on MS Windows, while os.system doesn't.
> Now, ultimately, I don't know if this really helps your
> exact situation but it least it should be clear what will
> and what won't work. Conclusion: use subprocess.call if
> you can.
More information about the Python-list