win32+popen4

Robin Becker robin at jessikat.fsnet.co.uk
Fri Mar 1 12:24:02 EST 2002


In article <a5o719$8l90f$1 at ID-59885.news.dfncis.de>, Thomas Heller <theller at python.net> writes
>"Robin Becker" <robin at jessikat.fsnet.co.uk> wrote in message news:PtFyMdAeY5f8Ew
>jI at jessikat.demon.co.uk...
>> after investigation it seems that module nt is using
>>         cmd.exe /c string
>>
>> to run programs and I can't find any way to quote things in the string.
>> A typically rubbish M$-ism.
>> --
>> Robin Becker
>
>On win2k it seems to be even documented (for the first time?):
wow, well there's hope yet. I of course looked in the win2k help which
is shorter than the /? output.

I used this function to quote for passing to system

def _quote(*args):
    fmt = max(map(lambda s: len(string.split(s)), args))>1 and '"%s"' or '%s'
    return fmt % string.join(map(lambda s: len(string.split(s))>1 and '"%s"' % s or s, args),' ')

then I can do

        system(_quote(r'c:\program files\bingo\bango.exe', r'c:\test dir\my rubbish.txt'))

and it seems to work. I guess spaces in filenames might be a
pain everywhere in win32 land. Does the same work in other win32's?
-- 
Robin Becker



More information about the Python-list mailing list