[Tutor] Why is this not working? Seems like a whitespace issue
alan.gauld at btinternet.com
Mon Feb 5 10:09:30 CET 2007
"Gizmo" <gizmo1 at gmail.com> wrote
>>>> import os
>>>> process=r"C:\Program Files\WinRAR\Rar.exe"
>>>> startDir = r"C:\to burn"
>>>> os.system(process+" x "+"C:\\to burn\\somemovie\\mymovie.rar"+"
> This doesnt work for me.. I get the error " 'C:\Program' is not
> whenever you have whitespaces in your path, ...enclose the
> whole path in double quotes; for example:
You got the right problem. The solution is to enclose your process
string in single quotes (or tripple quotes if you prefer!) That way
double quotes will be passed through untouched.
It would make your code slightly easier to maintain if you were
more consistent in the approach though. In some places you use
raw strings in others double escaped strings. That could lead
to confusion later.
Just a thought,
Author of the Learn to Program web site
More information about the Tutor