@@ -354,19 +354,27 @@ are able to handle the less common cases not covered by the convenience
354354functions.
355355
356356
357- .. class :: Popen(args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=True, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, restore_signals=True, start_new_session=False, pass_fds=())
357+ .. class :: Popen(args, bufsize=0, executable=None, stdin=None, stdout=None, \
358+ stderr=None, preexec_fn=None, close_fds=True, shell=False, \
359+ cwd=None, env=None, universal_newlines=False, \
360+ startupinfo=None, creationflags=0, restore_signals=True, \
361+ start_new_session=False, pass_fds=())
358362
359- Arguments are:
363+ Execute a child program in a new process. On Unix, the class uses
364+ :meth: `os.execvp `-like behavior to execute the child program. On Windows,
365+ the class uses the Windows ``CreateProcess() `` function. The arguments to
366+ :class: `Popen ` are as follows.
360367
361368 *args * should be a sequence of program arguments or else a single string.
362369 By default, the program to execute is the first item in *args * if *args * is
363- a sequence and the string itself if *args * is a string. However, see the
364- *shell * and *executable * arguments for differences from this behavior.
370+ a sequence. If *args * is a string, the interpretation is
371+ platform-dependent and described below. See the *shell * and *executable *
372+ arguments for additional differences from the default behavior. Unless
373+ otherwise stated, it is recommended to pass *args * as a sequence.
365374
366- On Unix, the :class: `Popen ` class uses :meth: `os.execvp `-like behavior to
367- execute the child program. If *args * is a string, the string is
368- interpreted as the name or path of the program to execute; this only works
369- if the program is being given no arguments.
375+ On Unix, if *args * is a string, the string is interpreted as the name or
376+ path of the program to execute. However, this can only be done if not
377+ passing arguments to the program.
370378
371379 .. note ::
372380
@@ -387,14 +395,13 @@ functions.
387395 used in the shell (such as filenames containing spaces or the *echo * command
388396 shown above) are single list elements.
389397
390- On Windows, the :class: `Popen ` class uses ``CreateProcess() `` to
391- execute the child program, which operates on strings. If *args * is a
392- sequence, it will be converted to a string in a manner described in
393- :ref: `converting-argument-sequence `.
398+ On Windows, if *args * is a sequence, it will be converted to a string in a
399+ manner described in :ref: `converting-argument-sequence `. This is because
400+ the underlying ``CreateProcess() `` operates on strings.
394401
395402 The *shell * argument (which defaults to *False *) specifies whether to use
396- the shell as the program to execute. It is recommended to pass * args * as a
397- sequence if * shell * is * False * and as a string if * shell * is * True * .
403+ the shell as the program to execute. If * shell * is * True *, it is
404+ recommended to pass * args * as a string rather than as a sequence .
398405
399406 On Unix with ``shell=True ``, the shell defaults to :file: `/bin/sh `. If
400407 *args * is a string, the string specifies the command
@@ -433,9 +440,10 @@ functions.
433440
434441 The *executable * argument specifies a replacement program to execute. It
435442 is very seldom needed. When ``shell=False ``, *executable * replaces the
436- program to execute specified by *args *. However, the *args * program is
437- still treated by most programs as the command name, which can then be
438- different from the program actually executed. On Unix, the *args * name
443+ program to execute specified by *args *. However, the original *args * is
444+ still passed to the program. Most programs treat the program specified
445+ by *args * as the command name, which can then be different from the program
446+ actually executed. On Unix, the *args * name
439447 becomes the display name for the executable in utilities such as
440448 :program: `ps `. If ``shell=True ``, on Unix the *executable * argument
441449 specifies a replacement shell for the default :file: `/bin/sh `.
0 commit comments