diff options
author | Tim D. Smith <github@tim-smith.us> | 2020-02-10 22:51:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-10 22:51:01 (GMT) |
commit | 95d024d585bd3ed627437a2f0cbc783c8a014c8a (patch) | |
tree | ce0b99739e1278a992fab6685daf6fc85ab71b1e /Doc/library/subprocess.rst | |
parent | 37c55b2b49a3acb7c56c9f6a5062bc6e4e35bc1c (diff) | |
download | cpython-95d024d585bd3ed627437a2f0cbc783c8a014c8a.zip cpython-95d024d585bd3ed627437a2f0cbc783c8a014c8a.tar.gz cpython-95d024d585bd3ed627437a2f0cbc783c8a014c8a.tar.bz2 |
bpo-13826: Clarify Popen constructor example (GH-18438)
Clarifies that the use of `shlex.split` is more instructive than
normative, and provides a simpler example.
https://bugs.python.org/issue13826
Diffstat (limited to 'Doc/library/subprocess.rst')
-rw-r--r-- | Doc/library/subprocess.rst | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst index 7485748..24497a2 100644 --- a/Doc/library/subprocess.rst +++ b/Doc/library/subprocess.rst @@ -356,14 +356,20 @@ functions. arguments for additional differences from the default behavior. Unless otherwise stated, it is recommended to pass *args* as a sequence. + An example of passing some arguments to an external program + as a sequence is:: + + Popen(["/usr/bin/git", "commit", "-m", "Fixes a bug."]) + On POSIX, if *args* is a string, the string is interpreted as the name or path of the program to execute. However, this can only be done if not passing arguments to the program. .. note:: - :meth:`shlex.split` can be useful when determining the correct - tokenization for *args*, especially in complex cases:: + It may not be obvious how to break a shell command into a sequence of arguments, + especially in complex cases. :meth:`shlex.split` can illustrate how to + determine the correct tokenization for *args*:: >>> import shlex, subprocess >>> command_line = input() |