A question about a list and subprocess.check_call()
David Aldrich
David.Aldrich at EMEA.NEC.COM
Tue Feb 17 04:32:03 EST 2015
>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().
More information about the Python-list
mailing list