On 28/05/2014 21:46, ps16thypresenceisfullnessof...@gmail.com wrote: > > Thank you for your replies. I tried what you suggested in your second > post and it worked. > > That was actually a mistake in the app_list.xml file. As you said: > > <app name="LibreOffice Writer">%ProgramFiles%\LibreOffice > 4\program\swriter.exe "C:\Users\Timothy\Documents\myfile.odt"</app> > > should instead be: > > <app name="LibreOffice Writer">"%ProgramFiles%\LibreOffice > 4\program\swriter.exe" "C:\Users\Timothy\Documents\myfile.odt"</app> > > I just made that file as a sample, and didn't actually test it. > > My "shlex dance" has nothing to do with that, though. A few examples > from the interactive interpreter should explain why I am doing it (I > used raw strings in these examples so that I wouldn't need to escape > the backslashes): > >>>> import shlex >>>> shlex.split(r'C:\Users\Timothy\Documents\Python\myscript.py') > ['C:UsersTimothyDocumentsPythonmyscript.py'] >>>> shlex.split(r'C:\\Users\\Timothy\\Documents\\Python\\myscript.py') > >>>> ['C:\\Users\\Timothy\\Documents\\Python\\myscript.py'] >>>> shlex.split(r'C:\Users\Timothy\Documents\Python\myscript.py', >>>> posix=False) > ['C:\\Users\\Timothy\\Documents\\Python\\myscript.py'] > > The first example shows that single backslashes get removed. The > second example shows that double backslashes are preserved intact. > The third example shows that if posix=False, single backslashes are > converted to double backslashes. None of these three behaviors are > acceptable to correctly parse a Windows path, which is why I am doing > what I am to work around the issue.
Well I certainly learnt something there! An additional test, which you don't show is this: >>> import shlex >>> shlex.split(r'"c:\users\timothy\documents"') ['c:\\users\\timothy\\documents'] >>> In other words, given the double-quoted data in your XML file, I think it will do the right thing by Windows backslashes. YMMV, I suppose. TJG -- https://mail.python.org/mailman/listinfo/python-list