bpo-13826: Clarify Popen constructor example (GH-18438) · python/cpython@95d024d (original) (raw)

`@@ -356,14 +356,20 @@ functions.

`

356

356

` arguments for additional differences from the default behavior. Unless

`

357

357

` otherwise stated, it is recommended to pass args as a sequence.

`

358

358

``

``

359

`+

An example of passing some arguments to an external program

`

``

360

`+

as a sequence is::

`

``

361

+

``

362

`+

Popen(["/usr/bin/git", "commit", "-m", "Fixes a bug."])

`

``

363

+

359

364

` On POSIX, if args is a string, the string is interpreted as the name or

`

360

365

` path of the program to execute. However, this can only be done if not

`

361

366

` passing arguments to the program.

`

362

367

``

363

368

` .. note::

`

364

369

``

365

``

`` -

:meth:shlex.split can be useful when determining the correct

``

366

``

`-

tokenization for args, especially in complex cases::

`

``

370

`+

It may not be obvious how to break a shell command into a sequence of arguments,

`

``

371

`` +

especially in complex cases. :meth:shlex.split can illustrate how to

``

``

372

`+

determine the correct tokenization for args::

`

367

373

``

368

374

` >>> import shlex, subprocess

`

369

375

` >>> command_line = input()

`