]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-13826: Clarify Popen constructor example (GH-18438)
authorTim D. Smith <github@tim-smith.us>
Mon, 10 Feb 2020 22:51:01 +0000 (14:51 -0800)
committerGitHub <noreply@github.com>
Mon, 10 Feb 2020 22:51:01 +0000 (14:51 -0800)
Clarifies that the use of `shlex.split` is more instructive than
normative, and provides a simpler example.

https://bugs.python.org/issue13826

Doc/library/subprocess.rst

index 74857480360dc92f03009d4a60aff235bb6ae94a..24497a2edd357712a72c91dde24ef1d1c7eb8fe6 100644 (file)
@@ -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()