X-Received: by 10.236.175.42 with SMTP id y30mr3440201yhl.42.1401391261186; Thu, 29 May 2014 12:21:01 -0700 (PDT) X-Received: by 10.140.44.75 with SMTP id f69mr178491qga.11.1401391260984; Thu, 29 May 2014 12:21:00 -0700 (PDT) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!hl10no7453395igb.0!news-out.google.com!qf4ni17772igc.0!nntp.google.com!c1no20231563igq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.python Date: Thu, 29 May 2014 12:21:00 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=108.52.73.71; posting-account=5ZUofAoAAACSkMmYQkuJJonc3AuNVoNk NNTP-Posting-Host: 108.52.73.71 References: <29c26176-b573-4ac9-bf41-a18a53d7dfb9@googlegroups.com> <53856F53.5010303@timgolden.me.uk> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Command prompt not shown when running Python script with subprocess on Windows From: ps16thypresenceisfullnessofjoy@gmail.com Injection-Date: Thu, 29 May 2014 19:21:01 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: csiph.com comp.lang.python:72248 That's interesting, now I learned something else too. As I said before, tho= ugh, I want users to be able to enter paths in the XML file exactly the way= they would be entered in a Windows shortcut. (Actually, my program currently only has one Windows user, for whom I devel= op it [I don't even use it myself :-0].) Since in a Windows shortcut you don't need to put quotes around a path that= doesn't contain spaces, I want to follow that behavior in my program as we= ll. So actually, I see that the line: "%ProgramFiles%\LibreOffice 4\program\swri= ter.exe" "C:\Users\Timothy\Documents\myfile.odt" should instead be: "%ProgramFiles%\LibreOffice 4\program\swri= ter.exe" C:\Users\Timothy\Documents\myfile.odt because there are no spaces in the second path, but there is a space in the= first one. So I guess I'll still have to do my "shlex dance" (which for some reason I = keep on mistyping as "shlex dane" :-)) unless I can learn a better way to d= o it. Also, is my calling os.path.expandvars only on the first argument a good id= ea? I want to accept environment variables in my program, but I don't want = to call os.path.expandvars on all the arguments, because I want to let othe= r programs take care of parsing their own arguments. I'm just wondering if I should relook at the whole way that I am doing thin= gs here. Maybe it would be better to just use shlex.split and subprocess.Po= pen and not try to follow the behavior of Windows shortcuts so closely? (Bu= t then it might be hard for some Windows users to understand how to use the= program if I didn't.) What do you think?