diff options
author | Martin Panter <vadmium+py@gmail.com> | 2016-07-29 01:49:37 (GMT) |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2016-07-29 01:49:37 (GMT) |
commit | 6a09315ff098224da138ff708e470ebc1c0ba8ac (patch) | |
tree | e21713f5da3e25fa00aaf284c51273d2acde2884 /Doc/library/subprocess.rst | |
parent | 10ea19f69c0bdb2c47aaa29c62dcb1f41825a3dc (diff) | |
parent | 1050d2d0c7730c6c533246bb2404937739a7775c (diff) | |
download | cpython-6a09315ff098224da138ff708e470ebc1c0ba8ac.zip cpython-6a09315ff098224da138ff708e470ebc1c0ba8ac.tar.gz cpython-6a09315ff098224da138ff708e470ebc1c0ba8ac.tar.bz2 |
Issue #26462: Merge code block fixes from 3.5
Diffstat (limited to 'Doc/library/subprocess.rst')
-rw-r--r-- | Doc/library/subprocess.rst | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst index 3da4574..ab20889 100644 --- a/Doc/library/subprocess.rst +++ b/Doc/library/subprocess.rst @@ -954,20 +954,23 @@ been imported from the :mod:`subprocess` module. Replacing /bin/sh shell backquote ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: bash output=`mycmd myarg` - # becomes - output = check_output(["mycmd", "myarg"]) +becomes:: + + output = check_output(["mycmd", "myarg"]) Replacing shell pipeline ^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: bash output=`dmesg | grep hda` - # becomes + +becomes:: + p1 = Popen(["dmesg"], stdout=PIPE) p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE) p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. @@ -977,10 +980,14 @@ The p1.stdout.close() call after starting the p2 is important in order for p1 to receive a SIGPIPE if p2 exits before p1. Alternatively, for trusted input, the shell's own pipeline support may still -be used directly:: +be used directly: + +.. code-block:: bash output=`dmesg | grep hda` - # becomes + +becomes:: + output=check_output("dmesg | grep hda", shell=True) |