Logged In: YES
user_id=1188172
I have made a documentation patch (attached here; where to
submit else?). However, since similar popen functions are
available in the os module, it is questionable if this
should be applied because there may be confusion about the
different signature.
Index: Doc/lib/libpopen2.tex
===================================================================
RCS file:
/cvsroot/python/python/dist/src/Doc/lib/libpopen2.tex,v
retrieving revision 1.17.2.2
diff -c -r1.17.2.2 libpopen2.tex
*** Doc/lib/libpopen2.tex 7 Jan 2005 06:57:26 -0000
1.17.2.2
--- Doc/lib/libpopen2.tex 2 Apr 2005 17:10:29 -0000
***************
*** 14,20 ****
Note that starting with Python 2.0, this functionality is
available
using functions from the \refmodule{os} module which have
the same
names as the factory functions here, but the order of the
return
! values is more intuitive in the \refmodule{os} module
variants.
The primary interface offered by this module is a trio of
factory
functions. For each of these, if \var{bufsize} is specified,
--- 14,21 ----
Note that starting with Python 2.0, this functionality is
available
using functions from the \refmodule{os} module which have
the same
names as the factory functions here, but the order of the
return
! values is different and more intuitive in the
\refmodule{os} module
! variants.
The primary interface offered by this module is a trio of
factory
functions. For each of these, if \var{bufsize} is specified,
***************
*** 29,55 ****
\function{os.spawnv()}). If \var{cmd} is a string it will
be passed to the
shell (as with \function{os.system()}).
The only way to retrieve the return codes for the child
processes is
by using the \method{poll()} or \method{wait()} methods on the
\class{Popen3} and \class{Popen4} classes; these are only
available on
\UNIX. This information is not available when using the
\function{popen2()}, \function{popen3()}, and
\function{popen4()}
functions, or the equivalent functions in the
\refmodule{os} module.
! (Note that the tuples returned by the \refmodule{os}
module's functions
! are in a different order from the ones returned by the
\module{popen2}
! module.)
! \begin{funcdesc}{popen2}{cmd\optional{, bufsize\optional{,
mode}}}
Executes \var{cmd} as a sub-process. Returns the file objects
\code{(\var{child_stdout}, \var{child_stdin})}.
\end{funcdesc}
! \begin{funcdesc}{popen3}{cmd\optional{, bufsize\optional{,
mode}}}
Executes \var{cmd} as a sub-process. Returns the file objects
\code{(\var{child_stdout}, \var{child_stdin},
\var{child_stderr})}.
\end{funcdesc}
! \begin{funcdesc}{popen4}{cmd\optional{, bufsize\optional{,
mode}}}
Executes \var{cmd} as a sub-process. Returns the file objects
\code{(\var{child_stdout_and_stderr}, \var{child_stdin})}.
\versionadded{2.0}
--- 30,59 ----
\function{os.spawnv()}). If \var{cmd} is a string it will
be passed to the
shell (as with \function{os.system()}).
+ \versionadded[If you specify the \var{env} parameter,
which is only available on \UNIX,
+ it will be the environment of the subprocess as described
for the
+ \function{spawn*e()} functions in the \refmodule{os}
module.]{2.5}
+
The only way to retrieve the return codes for the child
processes is
by using the \method{poll()} or \method{wait()} methods on the
\class{Popen3} and \class{Popen4} classes; these are only
available on
\UNIX. This information is not available when using the
\function{popen2()}, \function{popen3()}, and
\function{popen4()}
functions, or the equivalent functions in the
\refmodule{os} module.
! Also, you could use the \refmodule{subprocess} module
which provides
! a more general approach to spawning of child processes.
! \begin{funcdesc}{popen2}{cmd\optional{, bufsize\optional{,
mode\optional{, env}}}}
Executes \var{cmd} as a sub-process. Returns the file objects
\code{(\var{child_stdout}, \var{child_stdin})}.
\end{funcdesc}
! \begin{funcdesc}{popen3}{cmd\optional{, bufsize\optional{,
mode\optional{, env}}}}
Executes \var{cmd} as a sub-process. Returns the file objects
\code{(\var{child_stdout}, \var{child_stdin},
\var{child_stderr})}.
\end{funcdesc}
! \begin{funcdesc}{popen4}{cmd\optional{, bufsize\optional{,
mode\optional{, env}}}}
Executes \var{cmd} as a sub-process. Returns the file objects
\code{(\var{child_stdout_and_stderr}, \var{child_stdin})}.
\versionadded{2.0}
***************
*** 60,66 ****
functions is also available. These are not used for the
Windows
implementation, and are not available on that platform.
! \begin{classdesc}{Popen3}{cmd\optional{,
capturestderr\optional{, bufsize}}}
This class represents a child process. Normally,
\class{Popen3}
instances are created using the \function{popen2()} and
\function{popen3()} factory functions described above.
--- 64,70 ----
functions is also available. These are not used for the
Windows
implementation, and are not available on that platform.
! \begin{classdesc}{Popen3}{cmd\optional{,
capturestderr\optional{, bufsize\optional{, env}}}}
This class represents a child process. Normally,
\class{Popen3}
instances are created using the \function{popen2()} and
\function{popen3()} factory functions described above.
***************
*** 69,79 ****
objects, the parameter \var{cmd} is the shell command to
execute in a
sub-process. The \var{capturestderr} flag, if true,
specifies that
the object should capture standard error output of the
child process.
! The default is false. If the \var{bufsize} parameter is
specified, it
specifies the size of the I/O buffers to/from the child
process.
\end{classdesc}
! \begin{classdesc}{Popen4}{cmd\optional{, bufsize}}
Similar to \class{Popen3}, but always captures standard
error into the
same file object as standard output. These are typically
created
using \function{popen4()}.
--- 73,86 ----
objects, the parameter \var{cmd} is the shell command to
execute in a
sub-process. The \var{capturestderr} flag, if true,
specifies that
the object should capture standard error output of the
child process.
! The default is false. If the \var{bufsize} parameter is
given, it
specifies the size of the I/O buffers to/from the child
process.
+ If the \var{env} parameter is given (it must be a
mapping), it will
+ be the environment of the new process (instead of a copy
of the
+ current process's).
\end{classdesc}
! \begin{classdesc}{Popen4}{cmd\optional{,
bufsize\optional{, env}}}
Similar to \class{Popen3}, but always captures standard
error into the
same file object as standard output. These are typically
created
using \function{popen4()}.
|