[Python-checkins] bpo-13826: Clarify Popen constructor example (GH-18438)
Miss Islington (bot)
webhook-mailer at python.org
Mon Feb 10 17:56:19 EST 2020
https://github.com/python/cpython/commit/78982f94faaa05e363d15b49ec230d11a4d8bebd
commit: 78982f94faaa05e363d15b49ec230d11a4d8bebd
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-02-10T14:56:14-08:00
summary:
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
(cherry picked from commit 95d024d585bd3ed627437a2f0cbc783c8a014c8a)
Co-authored-by: Tim D. Smith <github at tim-smith.us>
files:
M Doc/library/subprocess.rst
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst
index f9ace66295215..69737820f37d8 100644
--- a/Doc/library/subprocess.rst
+++ b/Doc/library/subprocess.rst
@@ -354,14 +354,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()
More information about the Python-checkins
mailing list