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

Skip to content

Commit af265f4

Browse files
committed
Merged revisions 67531-67532,67538,67553-67554,67556-67557,67571,67574-67575,67579-67580,67591,67597,67608,67631 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r67531 | georg.brandl | 2008-12-04 19:54:05 +0100 (Thu, 04 Dec 2008) | 2 lines Add reference to enumerate() to indices example. ........ r67532 | georg.brandl | 2008-12-04 19:59:16 +0100 (Thu, 04 Dec 2008) | 2 lines Add another heapq example. ........ r67538 | georg.brandl | 2008-12-04 22:28:16 +0100 (Thu, 04 Dec 2008) | 2 lines Clarification to avoid confusing output with file descriptors. ........ r67553 | georg.brandl | 2008-12-05 08:49:49 +0100 (Fri, 05 Dec 2008) | 2 lines #4408: document regex.groups. ........ r67554 | georg.brandl | 2008-12-05 08:52:26 +0100 (Fri, 05 Dec 2008) | 2 lines #4409: fix asterisks looking like footnotes. ........ r67556 | georg.brandl | 2008-12-05 09:02:17 +0100 (Fri, 05 Dec 2008) | 2 lines #4441: improve doc for os.open() flags. ........ r67557 | georg.brandl | 2008-12-05 09:06:57 +0100 (Fri, 05 Dec 2008) | 2 lines Add an index entry for "subclassing immutable types". ........ r67571 | georg.brandl | 2008-12-05 10:13:45 +0100 (Fri, 05 Dec 2008) | 2 lines Use markup. ........ r67574 | georg.brandl | 2008-12-05 10:25:32 +0100 (Fri, 05 Dec 2008) | 2 lines #4441 followup: Add link to open() docs for Windows. ........ r67575 | georg.brandl | 2008-12-05 12:34:51 +0100 (Fri, 05 Dec 2008) | 2 lines #4544: add `dedent` to textwrap.__all__. ........ r67579 | georg.brandl | 2008-12-05 16:29:39 +0100 (Fri, 05 Dec 2008) | 2 lines #4517: add "special method" glossary entry and clarify when __getattribute__ is bypassed. ........ r67580 | georg.brandl | 2008-12-05 16:32:29 +0100 (Fri, 05 Dec 2008) | 2 lines #4478: document that copyfile() can raise Error. ........ r67591 | georg.brandl | 2008-12-05 19:00:06 +0100 (Fri, 05 Dec 2008) | 2 lines Followup to #4511: add link from decorator glossary entry to definition. ........ r67597 | georg.brandl | 2008-12-05 20:03:19 +0100 (Fri, 05 Dec 2008) | 2 lines Remove confusing sentence part. ........ r67608 | georg.brandl | 2008-12-06 12:57:12 +0100 (Sat, 06 Dec 2008) | 2 lines Follow-up to #4488: document PIPE and STDOUT properly. ........ r67631 | georg.brandl | 2008-12-07 12:54:07 +0100 (Sun, 07 Dec 2008) | 2 lines Add link to the favicon to the docs. ........
1 parent eb9fc52 commit af265f4

12 files changed

Lines changed: 94 additions & 42 deletions

File tree

Doc/documenting/rest.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Source Code
9898
-----------
9999

100100
Literal code blocks are introduced by ending a paragraph with the special marker
101-
``::``. The literal block must be indented, to be able to include blank lines::
101+
``::``. The literal block must be indented::
102102

103103
This is a normal text paragraph. The next paragraph is a code sample::
104104

Doc/glossary.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ Glossary
116116
def f(...):
117117
...
118118

119-
The same concept exists for classes, but is less commonly used there.
119+
The same concept exists for classes, but is less commonly used there. See
120+
the documentation for :ref:`function definitions <function>` and
121+
:ref:`class definitions <class>` for more about decorators.
120122

121123
descriptor
122124
Any object which defines the methods :meth:`__get__`, :meth:`__set__`, or
@@ -479,6 +481,12 @@ Glossary
479481
when several are given, such as in ``variable_name[1:3:5]``. The bracket
480482
(subscript) notation uses :class:`slice` objects internally.
481483

484+
special method
485+
A method that is called implicitly by Python to execute a certain
486+
operation on a type, such as addition. Such methods have names starting
487+
and ending with double underscores. Special methods are documented in
488+
:ref:`specialnames`.
489+
482490
statement
483491
A statement is part of a suite (a "block" of code). A statement is either
484492
an :term:`expression` or a one of several constructs with a keyword, such

Doc/library/getopt.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ exception:
6363
non-option argument is encountered.
6464

6565
If the first character of the option string is '+', or if the environment
66-
variable POSIXLY_CORRECT is set, then option processing stops as soon as a
67-
non-option argument is encountered.
66+
variable :envvar:`POSIXLY_CORRECT` is set, then option processing stops as
67+
soon as a non-option argument is encountered.
6868

6969

7070
.. exception:: GetoptError

Doc/library/heapq.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,21 @@ Example of use:
8686
>>> data == ordered
8787
True
8888

89+
Using a heap to insert items at the correct place in a priority queue:
90+
91+
>>> heap = []
92+
>>> data = [(1, 'J'), (4, 'N'), (3, 'H'), (2, 'O')]
93+
>>> for item in data:
94+
... heappush(heap, item)
95+
...
96+
>>> while heap:
97+
... print(heappop(heap)[1])
98+
J
99+
O
100+
H
101+
N
102+
103+
89104
The module also offers three general purpose functions based on heaps.
90105

91106

Doc/library/os.rst

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,11 @@ by file descriptors.
567567
:func:`fdopen`, or :data:`sys.stdout` or :data:`sys.stderr`, use its :meth:`write`
568568
method.
569569

570-
The following data items are available for use in constructing the *flags*
571-
parameter to the :func:`open` function. Some items will not be available on all
572-
platforms. For descriptions of their availability and use, consult
573-
:manpage:`open(2)`.
570+
The following constants are options for the *flags* parameter to the
571+
:func:`open` function. They can be combined using the bitwise OR operator
572+
``|``. Some of them are not available on all platforms. For descriptions of
573+
their availability and use, consult the :manpage:`open(2)` manual page on Unix
574+
or `the MSDN <http://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>` on Windows.
574575

575576

576577
.. data:: O_RDONLY
@@ -581,8 +582,7 @@ platforms. For descriptions of their availability and use, consult
581582
O_EXCL
582583
O_TRUNC
583584

584-
Options for the *flag* argument to the :func:`open` function. These can be
585-
combined using the bitwise OR operator ``|``. Availability: Unix, Windows.
585+
These constants are available on Unix and Windows.
586586

587587

588588
.. data:: O_DSYNC
@@ -594,8 +594,7 @@ platforms. For descriptions of their availability and use, consult
594594
O_SHLOCK
595595
O_EXLOCK
596596

597-
More options for the *flag* argument to the :func:`open` function. Availability:
598-
Unix.
597+
These constants are only available on Unix.
599598

600599

601600
.. data:: O_BINARY
@@ -606,8 +605,7 @@ platforms. For descriptions of their availability and use, consult
606605
O_SEQUENTIAL
607606
O_TEXT
608607

609-
Options for the *flag* argument to the :func:`open` function. These can be
610-
combined using the bitwise OR operator ``|``. Availability: Windows.
608+
These constants are only available on Windows.
611609

612610

613611
.. data:: O_ASYNC
@@ -616,8 +614,8 @@ platforms. For descriptions of their availability and use, consult
616614
O_NOFOLLOW
617615
O_NOATIME
618616

619-
Options for the *flag* argument to the :func:`open` function. These are
620-
GNU extensions and not present if they are not defined by the C library.
617+
These constants are GNU extensions and not present if they are not defined by
618+
the C library.
621619

622620

623621
.. data:: SEEK_SET

Doc/library/re.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,11 @@ attributes:
770770
were provided.
771771

772772

773+
.. attribute:: RegexObject.groups
774+
775+
The number of capturing groups in the pattern.
776+
777+
773778
.. attribute:: RegexObject.groupindex
774779

775780
A dictionary mapping any symbolic group names defined by ``(?P<id>)`` to group

Doc/library/shutil.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ copying and removal. For operations on individual files, see also the
4343

4444
Copy the contents (no metadata) of the file named *src* to a file named *dst*.
4545
*dst* must be the complete target file name; look at :func:`copy` for a copy that
46-
accepts a target directory path.
46+
accepts a target directory path. If *src* and *dst* are the same files,
47+
:exc:`Error` is raised.
4748
The destination location must be writable; otherwise, an :exc:`IOError` exception
4849
will be raised. If *dst* already exists, it will be replaced. Special files
4950
such as character or block devices and pipes cannot be copied with this

Doc/library/subprocess.rst

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ This module defines one class called :class:`Popen`:
6868
specified by the :envvar:`COMSPEC` environment variable.
6969

7070
*stdin*, *stdout* and *stderr* specify the executed programs' standard input,
71-
standard output and standard error file handles, respectively. Valid values are
72-
``PIPE``, an existing file descriptor (a positive integer), an existing file
73-
object, and ``None``. ``PIPE`` indicates that a new pipe to the child should be
74-
created. With ``None``, no redirection will occur; the child's file handles
75-
will be inherited from the parent. Additionally, *stderr* can be ``STDOUT``,
76-
which indicates that the stderr data from the applications should be captured
77-
into the same file handle as for stdout.
71+
standard output and standard error file handles, respectively. Valid values
72+
are :data:`PIPE`, an existing file descriptor (a positive integer), an
73+
existing file object, and ``None``. :data:`PIPE` indicates that a new pipe
74+
to the child should be created. With ``None``, no redirection will occur;
75+
the child's file handles will be inherited from the parent. Additionally,
76+
*stderr* can be :data:`STDOUT`, which indicates that the stderr data from the
77+
applications should be captured into the same file handle as for stdout.
7878

7979
If *preexec_fn* is set to a callable object, this object will be called in the
8080
child process just before the child is executed. (Unix only)
@@ -114,6 +114,20 @@ This module defines one class called :class:`Popen`:
114114
of the main window and priority for the new process. (Windows only)
115115

116116

117+
.. data:: PIPE
118+
119+
Special value that can be used as the *stdin*, *stdout* or *stderr* argument
120+
to :class:`Popen` and indicates that a pipe to the standard stream should be
121+
opened.
122+
123+
124+
.. data:: STDOUT
125+
126+
Special value that can be used as the *stderr* argument to :class:`Popen` and
127+
indicates that standard error should go into the same handle as standard
128+
output.
129+
130+
117131
Convenience Functions
118132
^^^^^^^^^^^^^^^^^^^^^
119133

@@ -229,7 +243,7 @@ Instances of the :class:`Popen` class have the following methods:
229243
*input* argument should be a byte string to be sent to the child process, or
230244
``None``, if no data should be sent to the child.
231245

232-
:meth:`communicate` returns a tuple ``(stdout, stderr)``.
246+
:meth:`communicate` returns a tuple ``(stdoutdata, stderrdata)``.
233247

234248
Note that if you want to send data to the process's stdin, you need to create
235249
the Popen object with ``stdin=PIPE``. Similarly, to get anything other than
@@ -277,20 +291,21 @@ The following attributes are also available:
277291

278292
.. attribute:: Popen.stdin
279293

280-
If the *stdin* argument is ``PIPE``, this attribute is a file object that
281-
provides input to the child process. Otherwise, it is ``None``.
294+
If the *stdin* argument was :data:`PIPE`, this attribute is a file object
295+
that provides input to the child process. Otherwise, it is ``None``.
282296

283297

284298
.. attribute:: Popen.stdout
285299

286-
If the *stdout* argument is ``PIPE``, this attribute is a file object that
287-
provides output from the child process. Otherwise, it is ``None``.
300+
If the *stdout* argument was :data:`PIPE`, this attribute is a file object
301+
that provides output from the child process. Otherwise, it is ``None``.
288302

289303

290304
.. attribute:: Popen.stderr
291305

292-
If the *stderr* argument is ``PIPE``, this attribute is file object that
293-
provides error output from the child process. Otherwise, it is ``None``.
306+
If the *stderr* argument was :data:`PIPE`, this attribute is a file object
307+
that provides error output from the child process. Otherwise, it is
308+
``None``.
294309

295310

296311
.. attribute:: Popen.pid
@@ -374,8 +389,8 @@ A more realistic example would look like this::
374389
print("Execution failed:", e, file=sys.stderr)
375390

376391

377-
Replacing os.spawn\*
378-
^^^^^^^^^^^^^^^^^^^^
392+
Replacing the os.spawn family
393+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
379394

380395
P_NOWAIT example::
381396

@@ -402,8 +417,8 @@ Environment example::
402417
Popen(["/bin/mycmd", "myarg"], env={"PATH": "/usr/bin"})
403418

404419

405-
Replacing os.popen\*
406-
^^^^^^^^^^^^^^^^^^^^
420+
Replacing os.popen
421+
^^^^^^^^^^^^^^^^^^
407422

408423
::
409424

@@ -416,4 +431,3 @@ Replacing os.popen\*
416431
pipe = os.popen(cmd, 'w', bufsize)
417432
==>
418433
pipe = Popen(cmd, shell=True, bufsize=bufsize, stdin=PIPE).stdin
419-

Doc/reference/datamodel.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,9 +1009,10 @@ of this is the :class:`NodeList` interface in the W3C's Document Object Model.)
10091009
Basic customization
10101010
-------------------
10111011

1012-
10131012
.. method:: object.__new__(cls[, ...])
10141013

1014+
.. index:: pair: subclassing; immutable types
1015+
10151016
Called to create a new instance of class *cls*. :meth:`__new__` is a static
10161017
method (special-cased so you need not declare it as such) that takes the class
10171018
of which an instance was requested as its first argument. The remaining
@@ -1915,7 +1916,7 @@ the instance when looking up special methods::
19151916
True
19161917

19171918
In addition to bypassing any instance attributes in the interest of
1918-
correctness, implicit special method lookup may also bypass the
1919+
correctness, implicit special method lookup generally also bypasses the
19191920
:meth:`__getattribute__` method even of the object's metaclass::
19201921

19211922
>>> class Meta(type):

Doc/tools/sphinxext/layout.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{% extends "!layout.html" %}
22
{% block rootrellink %}
3-
<li><img src="{{ pathto('_static/py.png', 1) }}" alt="" style="vertical-align: middle; margin-top: -1px"/></li><li><a href="{{ pathto('index') }}">{{ shorttitle }}</a>{{ reldelim1 }}</li>
3+
<li><img src="{{ pathto('_static/py.png', 1) }}" alt=""
4+
style="vertical-align: middle; margin-top: -1px"/></li>
5+
<li><a href="{{ pathto('index') }}">{{ shorttitle }}</a>{{ reldelim1 }}</li>
6+
{% endblock %}
7+
{% block extrahead %}
8+
<link rel="shortcut icon" type="image/png" href="{{ pathto('_static/py.png', 1) }}" />
9+
{{ super() }}
410
{% endblock %}

0 commit comments

Comments
 (0)