Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f5a4292

Browse files
committed
#6490: Expand documentation for os.popen().
Patch by Sam Kimbrel.
1 parent f2dfa92 commit f5a4292

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

Doc/library/os.rst

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2730,10 +2730,27 @@ written in Python, such as a mail server's external command delivery program.
27302730
Availability: Unix.
27312731

27322732

2733-
.. function:: popen(...)
2734-
2735-
Run child processes, returning opened pipes for communications. These functions
2736-
are described in section :ref:`os-newstreams`.
2733+
.. function:: popen(command, mode='r', buffering=-1)
2734+
2735+
Open a pipe to or from *command*. The return value is an open file object
2736+
connected to the pipe, which can be read or written depending on whether *mode*
2737+
is ``'r'`` (default) or ``'w'``. The *buffering* argument has the same meaning as
2738+
the corresponding argument to the built-in :func:`open` function. The
2739+
returned file object reads or writes text strings rather than bytes.
2740+
2741+
The ``close`` method returns :const:`None` if the subprocess exited
2742+
successfully, or the subprocess's return code if there was an
2743+
error. On POSIX systems, if the return code is positive it
2744+
represents the return value of the process left-shifted by one
2745+
byte. If the return code is negative, the process was terminated
2746+
by the signal given by the negated value of the return code. (For
2747+
example, the return value might be ``- signal.SIGKILL`` if the
2748+
subprocess was killed.) On Windows systems, the return value
2749+
contains the signed integer return code from the child process.
2750+
2751+
This is implemented using :class:`subprocess.Popen`; see that class's
2752+
documentation for more powerful ways to manage and communicate with
2753+
subprocesses.
27372754

27382755

27392756
.. function:: spawnl(mode, path, ...)

0 commit comments

Comments
 (0)