Merged revisions 73026,73313,73511,73554 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r73026 | r.david.murray | 2009-05-29 15:30:27 -0400 (Fri, 29 May 2009) | 3 lines

  Issue 6141: document that the first item of args is still the
  command name even when executable is specified.
........
  r73313 | r.david.murray | 2009-06-08 20:44:22 -0400 (Mon, 08 Jun 2009) | 4 lines

  Issue 2947: document how return code handling translates from
  os.popen to subprocess.  Also fixes reference link in the
  os.spawn documentation.
........
  r73511 | r.david.murray | 2009-06-22 18:11:04 -0400 (Mon, 22 Jun 2009) | 2 lines

  Improve English phrasing.
........
  r73554 | r.david.murray | 2009-06-25 10:21:06 -0400 (Thu, 25 Jun 2009) | 2 lines

  Add a couple of missing function alias declarations to the turtle docs.
........
This commit is contained in:
R. David Murray 2009-06-25 17:40:52 +00:00
parent 8f08985422
commit 9f8a51c326
4 changed files with 33 additions and 14 deletions

View File

@ -151,7 +151,7 @@ available. They are listed here in alphabetical order.
``'exec'`` if *source* consists of a sequence of statements, ``'eval'`` if it
consists of a single expression, or ``'single'`` if it consists of a single
interactive statement (in the latter case, expression statements that
evaluate to something else than ``None`` will be printed).
evaluate to something other than ``None`` will be printed).
The optional arguments *flags* and *dont_inherit* control which future
statements (see :pep:`236`) affect the compilation of *source*. If neither

View File

@ -1710,8 +1710,8 @@ written in Python, such as a mail server's external command delivery program.
(Note that the :mod:`subprocess` module provides more powerful facilities for
spawning new processes and retrieving their results; using that module is
preferable to using these functions. Check specially the *Replacing Older
Functions with the subprocess Module* section in that documentation page.)
preferable to using these functions. Check especially the
:ref:`subprocess-replacements` section.)
If *mode* is :const:`P_NOWAIT`, this function returns the process id of the new
process; if *mode* is :const:`P_WAIT`, returns the process's exit code if it

View File

@ -39,9 +39,12 @@ This module defines one class called :class:`Popen`:
Arguments are:
*args* should be a string, or a sequence of program arguments. The program
to execute is normally the first item in the args sequence or the string if a
string is given, but can be explicitly set by using the *executable*
argument.
to execute is normally the first item in the args sequence or the string if
a string is given, but can be explicitly set by using the *executable*
argument. When *executable* is given, the first item in the args sequence
is still treated by most programs as the command name, which can then be
different from the actual executable name. On Unix, it becomes the display
name for the executing program in utilities such as :program:`ps`.
On Unix, with *shell=False* (default): In this case, the Popen class uses
:meth:`os.execvp` to execute the child program. *args* should normally be a
@ -354,8 +357,8 @@ Replacing shell pipeline
output = p2.communicate()[0]
Replacing os.system()
^^^^^^^^^^^^^^^^^^^^^
Replacing :func:`os.system`
^^^^^^^^^^^^^^^^^^^^^^^^^^^
::
@ -382,8 +385,8 @@ A more realistic example would look like this::
print >>sys.stderr, "Execution failed:", e
Replacing the os.spawn family
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Replacing the :func:`os.spawn <os.spawnl>` family
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
P_NOWAIT example::
@ -410,8 +413,8 @@ Environment example::
Popen(["/bin/mycmd", "myarg"], env={"PATH": "/usr/bin"})
Replacing os.popen, os.popen2, os.popen3
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Replacing :func:`os.popen`, :func:`os.popen2`, :func:`os.popen3`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
::
@ -453,9 +456,23 @@ Replacing os.popen, os.popen2, os.popen3
stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
(child_stdin, child_stdout_and_stderr) = (p.stdin, p.stdout)
Return code handling translates as follows::
Replacing functions from the popen2 module
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pipe = os.popen(cmd, 'w')
...
rc = pipe.close()
if rc != None and rc % 256:
print "There were some errors"
==>
process = Popen(cmd, 'w', stdin=PIPE)
...
process.stdin.close()
if process.wait() != 0:
print "There were some errors"
Replacing functions from the :mod:`popen2` module
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. note::

View File

@ -1140,6 +1140,7 @@ Appearance
.. function:: shapesize(stretch_wid=None, stretch_len=None, outline=None)
turtlesize(stretch_wid=None, stretch_len=None, outline=None)
:param stretch_wid: positive number
:param stretch_len: positive number
@ -1332,6 +1333,7 @@ Special Turtle methods
.. function:: getturtle()
getpen()
Return the Turtle object itself. Only reasonable use: as a function to
return the "anonymous turtle":