mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge revs 56695--56698 to 3k tree.
This commit is contained in:
parent
4c801894ec
commit
d0a6b3d1c3
@ -18,8 +18,8 @@ available. They are listed here in alphabetical order.
|
||||
|
||||
.. note::
|
||||
|
||||
This is an advanced function that is not needed in everyday Python
|
||||
programming.
|
||||
This is an advanced function that is not needed in everyday Python
|
||||
programming.
|
||||
|
||||
The function is invoked by the :keyword:`import` statement. It mainly exists
|
||||
so that you can replace it with another function that has a compatible
|
||||
@ -355,12 +355,12 @@ available. They are listed here in alphabetical order.
|
||||
:func:`enumerate` is useful for obtaining an indexed series: ``(0, seq[0])``,
|
||||
``(1, seq[1])``, ``(2, seq[2])``, .... For example::
|
||||
|
||||
>>> for i, season in enumerate(['Spring', 'Summer', 'Fall', 'Winter')]:
|
||||
>>> print i, season
|
||||
0 Spring
|
||||
1 Summer
|
||||
2 Fall
|
||||
3 Winter
|
||||
>>> for i, season in enumerate(['Spring', 'Summer', 'Fall', 'Winter')]:
|
||||
>>> print i, season
|
||||
0 Spring
|
||||
1 Summer
|
||||
2 Fall
|
||||
3 Winter
|
||||
|
||||
.. versionadded:: 2.3
|
||||
|
||||
|
@ -16,7 +16,12 @@ available. They are listed here in alphabetical order.
|
||||
module: rexec
|
||||
module: imp
|
||||
|
||||
This function is invoked by the :keyword:`import` statement. It mainly exists
|
||||
.. note::
|
||||
|
||||
This is an advanced function that is not needed in everyday Python
|
||||
programming.
|
||||
|
||||
The function is invoked by the :keyword:`import` statement. It mainly exists
|
||||
so that you can replace it with another function that has a compatible
|
||||
interface, in order to change the semantics of the :keyword:`import` statement.
|
||||
For examples of why and how you would do this, see the standard library modules
|
||||
@ -138,7 +143,8 @@ available. They are listed here in alphabetical order.
|
||||
Return a string of one character whose ASCII code is the integer *i*. For
|
||||
example, ``chr(97)`` returns the string ``'a'``. This is the inverse of
|
||||
:func:`ord`. The argument must be in the range [0..255], inclusive;
|
||||
:exc:`ValueError` will be raised if *i* is outside that range.
|
||||
:exc:`ValueError` will be raised if *i* is outside that range. See
|
||||
also :func:`unichr`.
|
||||
|
||||
|
||||
.. function:: classmethod(function)
|
||||
@ -346,7 +352,14 @@ available. They are listed here in alphabetical order.
|
||||
iterator returned by :func:`enumerate` returns a tuple containing a count (from
|
||||
zero) and the corresponding value obtained from iterating over *iterable*.
|
||||
:func:`enumerate` is useful for obtaining an indexed series: ``(0, seq[0])``,
|
||||
``(1, seq[1])``, ``(2, seq[2])``, ....
|
||||
``(1, seq[1])``, ``(2, seq[2])``, .... For example::
|
||||
|
||||
>>> for i, season in enumerate(['Spring', 'Summer', 'Fall', 'Winter')]:
|
||||
>>> print i, season
|
||||
0 Spring
|
||||
1 Summer
|
||||
2 Fall
|
||||
3 Winter
|
||||
|
||||
.. versionadded:: 2.3
|
||||
|
||||
@ -1018,6 +1031,14 @@ available. They are listed here in alphabetical order.
|
||||
acceptable to :func:`eval`; its goal is to return a printable string. If no
|
||||
argument is given, returns the empty string, ``''``.
|
||||
|
||||
For more information on strings see :ref:`typesseq` which describes
|
||||
sequence functionality (strings are sequences), and also the
|
||||
string-specific methods described in the :ref:`string-methods`
|
||||
section. To output formatted strings use template strings or the
|
||||
``%`` operator described in the :ref:`typesseq-strings` section. In
|
||||
addition see the :ref:`stringservices` section. See also
|
||||
:func:`unicode`.
|
||||
|
||||
|
||||
.. function:: sum(iterable[, start])
|
||||
|
||||
@ -1097,7 +1118,8 @@ available. They are listed here in alphabetical order.
|
||||
*i*. For example, ``unichr(97)`` returns the string ``u'a'``. This is the
|
||||
inverse of :func:`ord` for Unicode strings. The valid range for the argument
|
||||
depends how Python was configured -- it may be either UCS2 [0..0xFFFF] or UCS4
|
||||
[0..0x10FFFF]. :exc:`ValueError` is raised otherwise.
|
||||
[0..0x10FFFF]. :exc:`ValueError` is raised otherwise. For ASCII and 8-bit
|
||||
strings see :func:`chr`.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
@ -1127,6 +1149,14 @@ available. They are listed here in alphabetical order.
|
||||
string version or representation is requested and then converted to a Unicode
|
||||
string using the codec for the default encoding in ``'strict'`` mode.
|
||||
|
||||
For more information on Unicode strings see :ref:`typesseq` which describes
|
||||
sequence functionality (Unicode strings are sequences), and also the
|
||||
string-specific methods described in the :ref:`string-methods`
|
||||
section. To output formatted strings use template strings or the
|
||||
``%`` operator described in the :ref:`typesseq-strings` section. In
|
||||
addition see the :ref:`stringservices` section. See also
|
||||
:func:`str`.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
.. versionchanged:: 2.2
|
||||
|
@ -1,28 +1,38 @@
|
||||
.. _library-index:
|
||||
|
||||
###############################
|
||||
The Python standard library
|
||||
The Python Standard Library
|
||||
###############################
|
||||
|
||||
:Release: |version|
|
||||
:Date: |today|
|
||||
|
||||
While :ref:`reference-index` describes the exact syntax and semantics of the
|
||||
language, it does not describe the standard library that is distributed with the
|
||||
language, and which greatly enhances its immediate usability. This library
|
||||
contains built-in modules (written in C) that provide access to system
|
||||
functionality such as file I/O that would otherwise be inaccessible to Python
|
||||
programmers, as well as modules written in Python that provide standardized
|
||||
solutions for many problems that occur in everyday programming. Some of these
|
||||
modules are explicitly designed to encourage and enhance the portability of
|
||||
Python programs.
|
||||
While the :ref:`reference-index` describes the exact syntax and
|
||||
semantics of the Python language, this library reference manual
|
||||
describes the standard library that is distributed with Python. It also
|
||||
describes some of the optional components that are commonly included
|
||||
in Python distributions.
|
||||
|
||||
This library reference manual documents Python's standard library, as well as
|
||||
many optional library modules (which may or may not be available, depending on
|
||||
whether the underlying platform supports them and on the configuration choices
|
||||
made at compile time). It also documents the standard types of the language and
|
||||
its built-in functions and exceptions, many of which are not or incompletely
|
||||
documented in the Reference Manual.
|
||||
Python's standard library is very extensive, offering a wide range of
|
||||
facilities as indicated by the long table of contents listed below. The
|
||||
library contains built-in modules (written in C) that provide access to
|
||||
system functionality such as file I/O that would otherwise be
|
||||
inaccessible to Python programmers, as well as modules written in Python
|
||||
that provide standardized solutions for many problems that occur in
|
||||
everyday programming. Some of these modules are explicitly designed to
|
||||
encourage and enhance the portability of Python programs by abstracting
|
||||
away platform-specifics into platform-neutral APIs.
|
||||
|
||||
The Python installers for the Windows and Mac platforms usually include
|
||||
the entire standard library and often also include many additional
|
||||
components. For Unix-like operating systems Python is normally provided
|
||||
as a collection of packages, so it may be necessary to use the packaging
|
||||
tools provided with the operating system to obtain some or all of the
|
||||
optional components.
|
||||
|
||||
In addition to the standard library, there is a growing collection of
|
||||
over 2500 additional components available from the `Python Package Index
|
||||
<http://pypi.python.org/pypi>`_.
|
||||
|
||||
|
||||
.. toctree::
|
||||
|
@ -12,8 +12,8 @@ interpreter.
|
||||
|
||||
Historically (until release 2.2), Python's built-in types have differed from
|
||||
user-defined types because it was not possible to use the built-in types as the
|
||||
basis for object-oriented inheritance. This limitation does not exist any
|
||||
longer.
|
||||
basis for object-oriented inheritance. This limitation no longer
|
||||
exists.
|
||||
|
||||
.. index:: pair: built-in; types
|
||||
|
||||
@ -95,10 +95,10 @@ These are the Boolean operations, ordered by ascending priority:
|
||||
| ``x or y`` | if *x* is false, then *y*, else | \(1) |
|
||||
| | *x* | |
|
||||
+-------------+---------------------------------+-------+
|
||||
| ``x and y`` | if *x* is false, then *x*, else | \(1) |
|
||||
| ``x and y`` | if *x* is false, then *x*, else | \(2) |
|
||||
| | *y* | |
|
||||
+-------------+---------------------------------+-------+
|
||||
| ``not x`` | if *x* is false, then ``True``, | \(2) |
|
||||
| ``not x`` | if *x* is false, then ``True``, | \(3) |
|
||||
| | else ``False`` | |
|
||||
+-------------+---------------------------------+-------+
|
||||
|
||||
@ -110,9 +110,14 @@ These are the Boolean operations, ordered by ascending priority:
|
||||
Notes:
|
||||
|
||||
(1)
|
||||
These only evaluate their second argument if needed for their outcome.
|
||||
This is a short-circuit operator, so it only evaluates the second
|
||||
argument if the first one is :const:`False`.
|
||||
|
||||
(2)
|
||||
This is a short-circuit operator, so it only evaluates the second
|
||||
argument if the first one is :const:`True`.
|
||||
|
||||
(3)
|
||||
``not`` has a lower priority than non-Boolean operators, so ``not a == b`` is
|
||||
interpreted as ``not (a == b)``, and ``a == not b`` is a syntax error.
|
||||
|
||||
@ -550,6 +555,13 @@ are sequences of the same type; *n*, *i* and *j* are integers:
|
||||
| ``max(s)`` | largest item of *s* | |
|
||||
+------------------+--------------------------------+----------+
|
||||
|
||||
Sequence types also support comparisons. In particular, tuples and lists
|
||||
are compared lexicographically by comparing corresponding
|
||||
elements. This means that to compare equal, every element must compare
|
||||
equal and the two sequences must be of the same type and have the same
|
||||
length. (For full details see :ref:`comparisons` in the language
|
||||
reference.)
|
||||
|
||||
.. index::
|
||||
triple: operations on; sequence; types
|
||||
builtin: len
|
||||
|
@ -516,7 +516,7 @@ class DocumentationApplication(object):
|
||||
for modname in self.env.filemodules.get(page_id, ()):
|
||||
self.freqmodules[modname] += 1
|
||||
# comments enabled?
|
||||
comments = self.env.metadata[page_id].get('comments_enabled', True)
|
||||
comments = self.env.metadata[page_id].get('nocomments', False)
|
||||
|
||||
# how does the user want to view comments?
|
||||
commentmode = req.session.get('comments', 'inline') if comments else ''
|
||||
|
Loading…
Reference in New Issue
Block a user