Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #85735

RE: A question about a list and subprocess.check_call()

From David Aldrich <David.Aldrich@EMEA.NEC.COM>
Subject RE: A question about a list and subprocess.check_call()
Date 2015-02-17 09:32 +0000
References <CAL7_Mo_okCswN3P0pZvrsU2HiLjBsw4W8Nvqgzxfjuh7Aw-nkw@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.18782.1424165529.18130.python-list@python.org> (permalink)

Show all headers | View raw


>It's also possible to do it the other around using shlex.split. I prefer that version because 
>I can easily copy/paste the command from code to the shell, it's also more readable IMO:

> cmd = """python3 -O -c "import sys; print(sys.argv[1:])" foo bar "spam egg" """
> print(cmd)
> subprocess.check_call(shlex.split(cmd))

Thanks again for the replies to my question.  I especially like the solution of using shlex.split().
 

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

RE: A question about a list and subprocess.check_call() David Aldrich <David.Aldrich@EMEA.NEC.COM> - 2015-02-17 09:32 +0000

csiph-web