mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
[3.12] gh-101100: Sphinx warnings: pick the low hanging fruits (GH-107386) (GH-107419)
(cherry picked from commit f2d07d3289
)
This commit is contained in:
parent
34e6e14602
commit
d514e1439f
52 changed files with 125 additions and 139 deletions
|
@ -11,6 +11,12 @@ creation and deletion functions don't apply to booleans. The following macros
|
||||||
are available, however.
|
are available, however.
|
||||||
|
|
||||||
|
|
||||||
|
.. c:var:: PyTypeObject PyBool_Type
|
||||||
|
|
||||||
|
This instance of :c:type:`PyTypeObject` represents the Python boolean type; it
|
||||||
|
is the same object as :class:`bool` in the Python layer.
|
||||||
|
|
||||||
|
|
||||||
.. c:function:: int PyBool_Check(PyObject *o)
|
.. c:function:: int PyBool_Check(PyObject *o)
|
||||||
|
|
||||||
Return true if *o* is of type :c:data:`PyBool_Type`. This function always
|
Return true if *o* is of type :c:data:`PyBool_Type`. This function always
|
||||||
|
|
|
@ -81,13 +81,13 @@ How do I extract C values from a Python object?
|
||||||
|
|
||||||
That depends on the object's type. If it's a tuple, :c:func:`PyTuple_Size`
|
That depends on the object's type. If it's a tuple, :c:func:`PyTuple_Size`
|
||||||
returns its length and :c:func:`PyTuple_GetItem` returns the item at a specified
|
returns its length and :c:func:`PyTuple_GetItem` returns the item at a specified
|
||||||
index. Lists have similar functions, :c:func:`PyListSize` and
|
index. Lists have similar functions, :c:func:`PyList_Size` and
|
||||||
:c:func:`PyList_GetItem`.
|
:c:func:`PyList_GetItem`.
|
||||||
|
|
||||||
For bytes, :c:func:`PyBytes_Size` returns its length and
|
For bytes, :c:func:`PyBytes_Size` returns its length and
|
||||||
:c:func:`PyBytes_AsStringAndSize` provides a pointer to its value and its
|
:c:func:`PyBytes_AsStringAndSize` provides a pointer to its value and its
|
||||||
length. Note that Python bytes objects may contain null bytes so C's
|
length. Note that Python bytes objects may contain null bytes so C's
|
||||||
:c:func:`strlen` should not be used.
|
:c:func:`!strlen` should not be used.
|
||||||
|
|
||||||
To test the type of an object, first make sure it isn't ``NULL``, and then use
|
To test the type of an object, first make sure it isn't ``NULL``, and then use
|
||||||
:c:func:`PyBytes_Check`, :c:func:`PyTuple_Check`, :c:func:`PyList_Check`, etc.
|
:c:func:`PyBytes_Check`, :c:func:`PyTuple_Check`, :c:func:`PyList_Check`, etc.
|
||||||
|
|
|
@ -527,7 +527,7 @@ If you're in doubt about the detailed behavior of the curses
|
||||||
functions, consult the manual pages for your curses implementation,
|
functions, consult the manual pages for your curses implementation,
|
||||||
whether it's ncurses or a proprietary Unix vendor's. The manual pages
|
whether it's ncurses or a proprietary Unix vendor's. The manual pages
|
||||||
will document any quirks, and provide complete lists of all the
|
will document any quirks, and provide complete lists of all the
|
||||||
functions, attributes, and :const:`ACS_\*` characters available to
|
functions, attributes, and :ref:`ACS_\* <curses-acs-codes>` characters available to
|
||||||
you.
|
you.
|
||||||
|
|
||||||
Because the curses API is so large, some functions aren't supported in
|
Because the curses API is so large, some functions aren't supported in
|
||||||
|
|
|
@ -778,7 +778,7 @@ Notes:
|
||||||
|
|
||||||
(2)
|
(2)
|
||||||
On Unix, if the :envvar:`HOME` environment variable is not defined, the user's
|
On Unix, if the :envvar:`HOME` environment variable is not defined, the user's
|
||||||
home directory will be determined with the :func:`getpwuid` function from the
|
home directory will be determined with the :func:`~pwd.getpwuid` function from the
|
||||||
standard :mod:`pwd` module. This is done by the :func:`os.path.expanduser`
|
standard :mod:`pwd` module. This is done by the :func:`os.path.expanduser`
|
||||||
function used by Distutils.
|
function used by Distutils.
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ Task lifetime support
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
A third party task implementation should call the following functions to keep a task
|
A third party task implementation should call the following functions to keep a task
|
||||||
visible by :func:`asyncio.get_tasks` and :func:`asyncio.current_task`:
|
visible by :func:`asyncio.all_tasks` and :func:`asyncio.current_task`:
|
||||||
|
|
||||||
.. function:: _register_task(task)
|
.. function:: _register_task(task)
|
||||||
|
|
||||||
|
|
|
@ -276,4 +276,4 @@ the Future has a result::
|
||||||
:func:`concurrent.futures.as_completed` functions.
|
:func:`concurrent.futures.as_completed` functions.
|
||||||
|
|
||||||
- :meth:`asyncio.Future.cancel` accepts an optional ``msg`` argument,
|
- :meth:`asyncio.Future.cancel` accepts an optional ``msg`` argument,
|
||||||
but :func:`concurrent.futures.cancel` does not.
|
but :meth:`concurrent.futures.Future.cancel` does not.
|
||||||
|
|
|
@ -87,7 +87,8 @@ The :mod:`bz2` module contains:
|
||||||
compressed streams.
|
compressed streams.
|
||||||
|
|
||||||
:class:`BZ2File` provides all of the members specified by the
|
:class:`BZ2File` provides all of the members specified by the
|
||||||
:class:`io.BufferedIOBase`, except for :meth:`detach` and :meth:`truncate`.
|
:class:`io.BufferedIOBase`, except for :meth:`~io.BufferedIOBase.detach`
|
||||||
|
and :meth:`~io.IOBase.truncate`.
|
||||||
Iteration and the :keyword:`with` statement are supported.
|
Iteration and the :keyword:`with` statement are supported.
|
||||||
|
|
||||||
:class:`BZ2File` also provides the following method:
|
:class:`BZ2File` also provides the following method:
|
||||||
|
|
|
@ -163,12 +163,12 @@ interpreter objects as well as the following additions.
|
||||||
|
|
||||||
Push a line of source text to the interpreter. The line should not have a
|
Push a line of source text to the interpreter. The line should not have a
|
||||||
trailing newline; it may have internal newlines. The line is appended to a
|
trailing newline; it may have internal newlines. The line is appended to a
|
||||||
buffer and the interpreter's :meth:`runsource` method is called with the
|
buffer and the interpreter's :meth:`~InteractiveInterpreter.runsource` method is called with the
|
||||||
concatenated contents of the buffer as source. If this indicates that the
|
concatenated contents of the buffer as source. If this indicates that the
|
||||||
command was executed or invalid, the buffer is reset; otherwise, the command is
|
command was executed or invalid, the buffer is reset; otherwise, the command is
|
||||||
incomplete, and the buffer is left as it was after the line was appended. The
|
incomplete, and the buffer is left as it was after the line was appended. The
|
||||||
return value is ``True`` if more input is required, ``False`` if the line was
|
return value is ``True`` if more input is required, ``False`` if the line was
|
||||||
dealt with in some way (this is the same as :meth:`runsource`).
|
dealt with in some way (this is the same as :meth:`!runsource`).
|
||||||
|
|
||||||
|
|
||||||
.. method:: InteractiveConsole.resetbuffer()
|
.. method:: InteractiveConsole.resetbuffer()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
The :mod:`concurrent` package
|
The :mod:`!concurrent` package
|
||||||
=============================
|
==============================
|
||||||
|
|
||||||
Currently, there is only one module in this package:
|
Currently, there is only one module in this package:
|
||||||
|
|
||||||
|
|
|
@ -1648,6 +1648,8 @@ keys); also, the following keypad mappings are standard:
|
||||||
| :kbd:`Page Down` | KEY_NPAGE |
|
| :kbd:`Page Down` | KEY_NPAGE |
|
||||||
+------------------+-----------+
|
+------------------+-----------+
|
||||||
|
|
||||||
|
.. _curses-acs-codes:
|
||||||
|
|
||||||
The following table lists characters from the alternate character set. These are
|
The following table lists characters from the alternate character set. These are
|
||||||
inherited from the VT100 terminal, and will generally be available on software
|
inherited from the VT100 terminal, and will generally be available on software
|
||||||
emulations such as X terminals. When there is no graphic available, curses
|
emulations such as X terminals. When there is no graphic available, curses
|
||||||
|
|
|
@ -150,7 +150,7 @@ Import this class from the :mod:`email.charset` module.
|
||||||
.. method:: __str__()
|
.. method:: __str__()
|
||||||
|
|
||||||
Returns *input_charset* as a string coerced to lower
|
Returns *input_charset* as a string coerced to lower
|
||||||
case. :meth:`__repr__` is an alias for :meth:`__str__`.
|
case. :meth:`!__repr__` is an alias for :meth:`!__str__`.
|
||||||
|
|
||||||
|
|
||||||
.. method:: __eq__(other)
|
.. method:: __eq__(other)
|
||||||
|
|
|
@ -25,7 +25,7 @@ is especially true for :mimetype:`image/\*` and :mimetype:`text/\*` type message
|
||||||
containing binary data.
|
containing binary data.
|
||||||
|
|
||||||
The :mod:`email` package provides some convenient encoders in its
|
The :mod:`email` package provides some convenient encoders in its
|
||||||
:mod:`encoders` module. These encoders are actually used by the
|
:mod:`~email.encoders` module. These encoders are actually used by the
|
||||||
:class:`~email.mime.audio.MIMEAudio` and :class:`~email.mime.image.MIMEImage`
|
:class:`~email.mime.audio.MIMEAudio` and :class:`~email.mime.image.MIMEImage`
|
||||||
class constructors to provide default encodings. All encoder functions take
|
class constructors to provide default encodings. All encoder functions take
|
||||||
exactly one argument, the message object to encode. They usually extract the
|
exactly one argument, the message object to encode. They usually extract the
|
||||||
|
|
|
@ -274,9 +274,9 @@ in with information about the part.
|
||||||
.. rubric:: Footnotes
|
.. rubric:: Footnotes
|
||||||
|
|
||||||
.. [#] This statement assumes that you use the appropriate setting for
|
.. [#] This statement assumes that you use the appropriate setting for
|
||||||
``unixfrom``, and that there are no :mod:`policy` settings calling for
|
``unixfrom``, and that there are no :mod:`email.policy` settings calling for
|
||||||
automatic adjustments (for example,
|
automatic adjustments (for example,
|
||||||
:attr:`~email.policy.Policy.refold_source` must be ``none``, which is
|
:attr:`~email.policy.EmailPolicy.refold_source` must be ``none``, which is
|
||||||
*not* the default). It is also not 100% true, since if the message
|
*not* the default). It is also not 100% true, since if the message
|
||||||
does not conform to the RFC standards occasionally information about the
|
does not conform to the RFC standards occasionally information about the
|
||||||
exact original text is lost during parsing error recovery. It is a goal
|
exact original text is lost during parsing error recovery. It is a goal
|
||||||
|
|
|
@ -67,7 +67,7 @@ message objects.
|
||||||
with the base :class:`~email.message.Message` class *maxheaderlen* is
|
with the base :class:`~email.message.Message` class *maxheaderlen* is
|
||||||
accepted, but defaults to ``None``, which means that by default the line
|
accepted, but defaults to ``None``, which means that by default the line
|
||||||
length is controlled by the
|
length is controlled by the
|
||||||
:attr:`~email.policy.EmailPolicy.max_line_length` of the policy. The
|
:attr:`~email.policy.Policy.max_line_length` of the policy. The
|
||||||
*policy* argument may be used to override the default policy obtained
|
*policy* argument may be used to override the default policy obtained
|
||||||
from the message instance. This can be used to control some of the
|
from the message instance. This can be used to control some of the
|
||||||
formatting produced by the method, since the specified *policy* will be
|
formatting produced by the method, since the specified *policy* will be
|
||||||
|
@ -213,7 +213,7 @@ message objects.
|
||||||
del msg['subject']
|
del msg['subject']
|
||||||
msg['subject'] = 'Python roolz!'
|
msg['subject'] = 'Python roolz!'
|
||||||
|
|
||||||
If the :mod:`policy` defines certain headers to be unique (as the standard
|
If the :mod:`policy <email.policy>` defines certain headers to be unique (as the standard
|
||||||
policies do), this method may raise a :exc:`ValueError` when an attempt
|
policies do), this method may raise a :exc:`ValueError` when an attempt
|
||||||
is made to assign a value to such a header when one already exists. This
|
is made to assign a value to such a header when one already exists. This
|
||||||
behavior is intentional for consistency's sake, but do not depend on it
|
behavior is intentional for consistency's sake, but do not depend on it
|
||||||
|
@ -378,7 +378,7 @@ message objects.
|
||||||
deprecated.
|
deprecated.
|
||||||
|
|
||||||
Note that existing parameter values of headers may be accessed through
|
Note that existing parameter values of headers may be accessed through
|
||||||
the :attr:`~email.headerregistry.BaseHeader.params` attribute of the
|
the :attr:`~email.headerregistry.ParameterizedMIMEHeader.params` attribute of the
|
||||||
header value (for example, ``msg['Content-Type'].params['charset']``).
|
header value (for example, ``msg['Content-Type'].params['charset']``).
|
||||||
|
|
||||||
.. versionchanged:: 3.4 ``replace`` keyword was added.
|
.. versionchanged:: 3.4 ``replace`` keyword was added.
|
||||||
|
@ -691,7 +691,7 @@ message objects.
|
||||||
|
|
||||||
.. method:: clear_content()
|
.. method:: clear_content()
|
||||||
|
|
||||||
Remove the payload and all of the :exc:`Content-` headers, leaving
|
Remove the payload and all of the :mailheader:`!Content-` headers, leaving
|
||||||
all other headers intact and in their original order.
|
all other headers intact and in their original order.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,9 @@ returns the root object when you close the parser.
|
||||||
Note that the parser can be extended in limited ways, and of course you can
|
Note that the parser can be extended in limited ways, and of course you can
|
||||||
implement your own parser completely from scratch. All of the logic that
|
implement your own parser completely from scratch. All of the logic that
|
||||||
connects the :mod:`email` package's bundled parser and the
|
connects the :mod:`email` package's bundled parser and the
|
||||||
:class:`~email.message.EmailMessage` class is embodied in the :mod:`policy`
|
:class:`~email.message.EmailMessage` class is embodied in the :class:`~email.policy.Policy`
|
||||||
class, so a custom parser can create message object trees any way it finds
|
class, so a custom parser can create message object trees any way it finds
|
||||||
necessary by implementing custom versions of the appropriate :mod:`policy`
|
necessary by implementing custom versions of the appropriate :class:`!Policy`
|
||||||
methods.
|
methods.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ The :class:`dircmp` class
|
||||||
used to get various bits of information about the directory trees being
|
used to get various bits of information about the directory trees being
|
||||||
compared.
|
compared.
|
||||||
|
|
||||||
Note that via :meth:`__getattr__` hooks, all attributes are computed lazily,
|
Note that via :meth:`~object.__getattr__` hooks, all attributes are computed lazily,
|
||||||
so there is no speed penalty if only those attributes which are lightweight
|
so there is no speed penalty if only those attributes which are lightweight
|
||||||
to compute are used.
|
to compute are used.
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,7 @@ available for subclassing as well:
|
||||||
The keyword-only parameter *encoding* and *errors* are added.
|
The keyword-only parameter *encoding* and *errors* are added.
|
||||||
|
|
||||||
.. versionchanged:: 3.11
|
.. versionchanged:: 3.11
|
||||||
The ``'rU'`` and ``'U'`` modes and the :meth:`__getitem__` method have
|
The ``'rU'`` and ``'U'`` modes and the :meth:`!__getitem__` method have
|
||||||
been removed.
|
been removed.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@
|
||||||
:meth:`TopologicalSorter.done` is less than the number that have been
|
:meth:`TopologicalSorter.done` is less than the number that have been
|
||||||
returned by :meth:`TopologicalSorter.get_ready`.
|
returned by :meth:`TopologicalSorter.get_ready`.
|
||||||
|
|
||||||
The :meth:`~TopologicalSorter.__bool__` method of this class defers to
|
The :meth:`~object.__bool__` method of this class defers to
|
||||||
this function, so instead of::
|
this function, so instead of::
|
||||||
|
|
||||||
if ts.is_active():
|
if ts.is_active():
|
||||||
|
@ -204,7 +204,7 @@ The :mod:`graphlib` module defines the following exception classes:
|
||||||
in the working graph. If multiple cycles exist, only one undefined choice among them will
|
in the working graph. If multiple cycles exist, only one undefined choice among them will
|
||||||
be reported and included in the exception.
|
be reported and included in the exception.
|
||||||
|
|
||||||
The detected cycle can be accessed via the second element in the :attr:`~CycleError.args`
|
The detected cycle can be accessed via the second element in the :attr:`~BaseException.args`
|
||||||
attribute of the exception instance and consists in a list of nodes, such that each node is,
|
attribute of the exception instance and consists in a list of nodes, such that each node is,
|
||||||
in the graph, an immediate predecessor of the next node in the list. In the reported list,
|
in the graph, an immediate predecessor of the next node in the list. In the reported list,
|
||||||
the first and the last node will be the same, to make it clear that it is cyclic.
|
the first and the last node will be the same, to make it clear that it is cyclic.
|
||||||
|
|
|
@ -70,7 +70,7 @@ The module defines the following items:
|
||||||
.. class:: GzipFile(filename=None, mode=None, compresslevel=9, fileobj=None, mtime=None)
|
.. class:: GzipFile(filename=None, mode=None, compresslevel=9, fileobj=None, mtime=None)
|
||||||
|
|
||||||
Constructor for the :class:`GzipFile` class, which simulates most of the
|
Constructor for the :class:`GzipFile` class, which simulates most of the
|
||||||
methods of a :term:`file object`, with the exception of the :meth:`truncate`
|
methods of a :term:`file object`, with the exception of the :meth:`~io.IOBase.truncate`
|
||||||
method. At least one of *fileobj* and *filename* must be given a non-trivial
|
method. At least one of *fileobj* and *filename* must be given a non-trivial
|
||||||
value.
|
value.
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ The module defines the following items:
|
||||||
|
|
||||||
:class:`GzipFile` supports the :class:`io.BufferedIOBase` interface,
|
:class:`GzipFile` supports the :class:`io.BufferedIOBase` interface,
|
||||||
including iteration and the :keyword:`with` statement. Only the
|
including iteration and the :keyword:`with` statement. Only the
|
||||||
:meth:`truncate` method isn't implemented.
|
:meth:`~io.IOBase.truncate` method isn't implemented.
|
||||||
|
|
||||||
:class:`GzipFile` also provides the following method and attribute:
|
:class:`GzipFile` also provides the following method and attribute:
|
||||||
|
|
||||||
|
|
|
@ -244,7 +244,7 @@ by the SHAKE algorithm.
|
||||||
|
|
||||||
.. method:: shake.digest(length)
|
.. method:: shake.digest(length)
|
||||||
|
|
||||||
Return the digest of the data passed to the :meth:`update` method so far.
|
Return the digest of the data passed to the :meth:`~hash.update` method so far.
|
||||||
This is a bytes object of size *length* which may contain bytes in
|
This is a bytes object of size *length* which may contain bytes in
|
||||||
the whole range from 0 to 255.
|
the whole range from 0 to 255.
|
||||||
|
|
||||||
|
@ -507,9 +507,9 @@ Simple hashing
|
||||||
|
|
||||||
To calculate hash of some data, you should first construct a hash object by
|
To calculate hash of some data, you should first construct a hash object by
|
||||||
calling the appropriate constructor function (:func:`blake2b` or
|
calling the appropriate constructor function (:func:`blake2b` or
|
||||||
:func:`blake2s`), then update it with the data by calling :meth:`update` on the
|
:func:`blake2s`), then update it with the data by calling :meth:`~hash.update` on the
|
||||||
object, and, finally, get the digest out of the object by calling
|
object, and, finally, get the digest out of the object by calling
|
||||||
:meth:`digest` (or :meth:`hexdigest` for hex-encoded string).
|
:meth:`~hash.digest` (or :meth:`~hash.hexdigest` for hex-encoded string).
|
||||||
|
|
||||||
>>> from hashlib import blake2b
|
>>> from hashlib import blake2b
|
||||||
>>> h = blake2b()
|
>>> h = blake2b()
|
||||||
|
|
|
@ -145,10 +145,10 @@
|
||||||
|
|
||||||
An abstract base class for resource readers capable of serving
|
An abstract base class for resource readers capable of serving
|
||||||
the :meth:`importlib.resources.files` interface. Subclasses
|
the :meth:`importlib.resources.files` interface. Subclasses
|
||||||
:class:`importlib.resources.abc.ResourceReader` and provides
|
:class:`ResourceReader` and provides
|
||||||
concrete implementations of the :class:`importlib.resources.abc.ResourceReader`'s
|
concrete implementations of the :class:`!ResourceReader`'s
|
||||||
abstract methods. Therefore, any loader supplying
|
abstract methods. Therefore, any loader supplying
|
||||||
:class:`importlib.abc.TraversableResources` also supplies ResourceReader.
|
:class:`!TraversableResources` also supplies :class:`!ResourceReader`.
|
||||||
|
|
||||||
Loaders that wish to support resource reading are expected to
|
Loaders that wish to support resource reading are expected to
|
||||||
implement this interface.
|
implement this interface.
|
||||||
|
|
|
@ -192,7 +192,7 @@ Basic Usage
|
||||||
dictionaries will be sorted by key.
|
dictionaries will be sorted by key.
|
||||||
|
|
||||||
To use a custom :class:`JSONEncoder` subclass (e.g. one that overrides the
|
To use a custom :class:`JSONEncoder` subclass (e.g. one that overrides the
|
||||||
:meth:`default` method to serialize additional types), specify it with the
|
:meth:`~JSONEncoder.default` method to serialize additional types), specify it with the
|
||||||
*cls* kwarg; otherwise :class:`JSONEncoder` is used.
|
*cls* kwarg; otherwise :class:`JSONEncoder` is used.
|
||||||
|
|
||||||
.. versionchanged:: 3.6
|
.. versionchanged:: 3.6
|
||||||
|
@ -422,7 +422,7 @@ Encoders and Decoders
|
||||||
Added support for int- and float-derived Enum classes.
|
Added support for int- and float-derived Enum classes.
|
||||||
|
|
||||||
To extend this to recognize other objects, subclass and implement a
|
To extend this to recognize other objects, subclass and implement a
|
||||||
:meth:`default` method with another method that returns a serializable object
|
:meth:`~JSONEncoder.default` method with another method that returns a serializable object
|
||||||
for ``o`` if possible, otherwise it should call the superclass implementation
|
for ``o`` if possible, otherwise it should call the superclass implementation
|
||||||
(to raise :exc:`TypeError`).
|
(to raise :exc:`TypeError`).
|
||||||
|
|
||||||
|
@ -483,7 +483,7 @@ Encoders and Decoders
|
||||||
:exc:`TypeError`).
|
:exc:`TypeError`).
|
||||||
|
|
||||||
For example, to support arbitrary iterators, you could implement
|
For example, to support arbitrary iterators, you could implement
|
||||||
:meth:`default` like this::
|
:meth:`~JSONEncoder.default` like this::
|
||||||
|
|
||||||
def default(self, o):
|
def default(self, o):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -397,21 +397,21 @@ have specific values relative to the predefined levels. If you define a level
|
||||||
with the same numeric value, it overwrites the predefined value; the predefined
|
with the same numeric value, it overwrites the predefined value; the predefined
|
||||||
name is lost.
|
name is lost.
|
||||||
|
|
||||||
+--------------+---------------+
|
+-----------------------+---------------+
|
||||||
| Level | Numeric value |
|
| Level | Numeric value |
|
||||||
+==============+===============+
|
+=======================+===============+
|
||||||
| ``CRITICAL`` | 50 |
|
| .. py:data:: CRITICAL | 50 |
|
||||||
+--------------+---------------+
|
+-----------------------+---------------+
|
||||||
| ``ERROR`` | 40 |
|
| .. py:data:: ERROR | 40 |
|
||||||
+--------------+---------------+
|
+-----------------------+---------------+
|
||||||
| ``WARNING`` | 30 |
|
| .. py:data:: WARNING | 30 |
|
||||||
+--------------+---------------+
|
+-----------------------+---------------+
|
||||||
| ``INFO`` | 20 |
|
| .. py:data:: INFO | 20 |
|
||||||
+--------------+---------------+
|
+-----------------------+---------------+
|
||||||
| ``DEBUG`` | 10 |
|
| .. py:data:: DEBUG | 10 |
|
||||||
+--------------+---------------+
|
+-----------------------+---------------+
|
||||||
| ``NOTSET`` | 0 |
|
| .. py:data:: NOTSET | 0 |
|
||||||
+--------------+---------------+
|
+-----------------------+---------------+
|
||||||
|
|
||||||
|
|
||||||
.. _handler:
|
.. _handler:
|
||||||
|
|
|
@ -100,7 +100,8 @@ Reading and writing compressed files
|
||||||
*filters* arguments have the same meanings as for :class:`LZMACompressor`.
|
*filters* arguments have the same meanings as for :class:`LZMACompressor`.
|
||||||
|
|
||||||
:class:`LZMAFile` supports all the members specified by
|
:class:`LZMAFile` supports all the members specified by
|
||||||
:class:`io.BufferedIOBase`, except for :meth:`detach` and :meth:`truncate`.
|
:class:`io.BufferedIOBase`, except for :meth:`~io.BufferedIOBase.detach`
|
||||||
|
and :meth:`~io.IOBase.truncate`.
|
||||||
Iteration and the :keyword:`with` statement are supported.
|
Iteration and the :keyword:`with` statement are supported.
|
||||||
|
|
||||||
The following method is also provided:
|
The following method is also provided:
|
||||||
|
|
|
@ -38,7 +38,7 @@ File Operations
|
||||||
Lock part of a file based on file descriptor *fd* from the C runtime. Raises
|
Lock part of a file based on file descriptor *fd* from the C runtime. Raises
|
||||||
:exc:`OSError` on failure. The locked region of the file extends from the
|
:exc:`OSError` on failure. The locked region of the file extends from the
|
||||||
current file position for *nbytes* bytes, and may continue beyond the end of the
|
current file position for *nbytes* bytes, and may continue beyond the end of the
|
||||||
file. *mode* must be one of the :const:`LK_\*` constants listed below. Multiple
|
file. *mode* must be one of the :const:`!LK_\*` constants listed below. Multiple
|
||||||
regions in a file may be locked at the same time, but may not overlap. Adjacent
|
regions in a file may be locked at the same time, but may not overlap. Adjacent
|
||||||
regions are not merged; they must be unlocked individually.
|
regions are not merged; they must be unlocked individually.
|
||||||
|
|
||||||
|
|
|
@ -51,9 +51,19 @@ the Unix :program:`ftp` program and other FTP clients.
|
||||||
|
|
||||||
Exception raised by the :class:`~netrc.netrc` class when syntactical errors are
|
Exception raised by the :class:`~netrc.netrc` class when syntactical errors are
|
||||||
encountered in source text. Instances of this exception provide three
|
encountered in source text. Instances of this exception provide three
|
||||||
interesting attributes: :attr:`msg` is a textual explanation of the error,
|
interesting attributes:
|
||||||
:attr:`filename` is the name of the source file, and :attr:`lineno` gives the
|
|
||||||
line number on which the error was found.
|
.. attribute:: msg
|
||||||
|
|
||||||
|
Textual explanation of the error.
|
||||||
|
|
||||||
|
.. attribute:: filename
|
||||||
|
|
||||||
|
The name of the source file.
|
||||||
|
|
||||||
|
.. attribute:: lineno
|
||||||
|
|
||||||
|
The line number on which the error was found.
|
||||||
|
|
||||||
|
|
||||||
.. _netrc-objects:
|
.. _netrc-objects:
|
||||||
|
|
|
@ -59,9 +59,9 @@ truth tests, identity tests, and boolean operations:
|
||||||
__not__(obj)
|
__not__(obj)
|
||||||
|
|
||||||
Return the outcome of :keyword:`not` *obj*. (Note that there is no
|
Return the outcome of :keyword:`not` *obj*. (Note that there is no
|
||||||
:meth:`__not__` method for object instances; only the interpreter core defines
|
:meth:`!__not__` method for object instances; only the interpreter core defines
|
||||||
this operation. The result is affected by the :meth:`__bool__` and
|
this operation. The result is affected by the :meth:`~object.__bool__` and
|
||||||
:meth:`__len__` methods.)
|
:meth:`~object.__len__` methods.)
|
||||||
|
|
||||||
|
|
||||||
.. function:: truth(obj)
|
.. function:: truth(obj)
|
||||||
|
|
|
@ -148,7 +148,7 @@ A :class:`POP3` instance has the following methods:
|
||||||
.. method:: POP3.pass_(password)
|
.. method:: POP3.pass_(password)
|
||||||
|
|
||||||
Send password, response includes message count and mailbox size. Note: the
|
Send password, response includes message count and mailbox size. Note: the
|
||||||
mailbox on the server is locked until :meth:`~poplib.quit` is called.
|
mailbox on the server is locked until :meth:`~POP3.quit` is called.
|
||||||
|
|
||||||
|
|
||||||
.. method:: POP3.apop(user, secret)
|
.. method:: POP3.apop(user, secret)
|
||||||
|
|
|
@ -45,7 +45,7 @@ The :mod:`pprint` module defines one class:
|
||||||
several keyword parameters.
|
several keyword parameters.
|
||||||
|
|
||||||
*stream* (default ``sys.stdout``) is a :term:`file-like object` to
|
*stream* (default ``sys.stdout``) is a :term:`file-like object` to
|
||||||
which the output will be written by calling its :meth:`write` method.
|
which the output will be written by calling its :meth:`!write` method.
|
||||||
If both *stream* and ``sys.stdout`` are ``None``, then
|
If both *stream* and ``sys.stdout`` are ``None``, then
|
||||||
:meth:`~PrettyPrinter.pprint` silently returns.
|
:meth:`~PrettyPrinter.pprint` silently returns.
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ The :mod:`pty` module defines the following functions:
|
||||||
|
|
||||||
Return the exit status value from :func:`os.waitpid` on the child process.
|
Return the exit status value from :func:`os.waitpid` on the child process.
|
||||||
|
|
||||||
:func:`waitstatus_to_exitcode` can be used to convert the exit status into
|
:func:`os.waitstatus_to_exitcode` can be used to convert the exit status into
|
||||||
an exit code.
|
an exit code.
|
||||||
|
|
||||||
.. audit-event:: pty.spawn argv pty.spawn
|
.. audit-event:: pty.spawn argv pty.spawn
|
||||||
|
|
|
@ -115,7 +115,7 @@ Scheduler Objects
|
||||||
|
|
||||||
.. method:: scheduler.run(blocking=True)
|
.. method:: scheduler.run(blocking=True)
|
||||||
|
|
||||||
Run all scheduled events. This method will wait (using the :func:`delayfunc`
|
Run all scheduled events. This method will wait (using the *delayfunc*
|
||||||
function passed to the constructor) for the next event, then execute it and so
|
function passed to the constructor) for the next event, then execute it and so
|
||||||
on until there are no more scheduled events.
|
on until there are no more scheduled events.
|
||||||
|
|
||||||
|
|
|
@ -60,9 +60,9 @@ constants below:
|
||||||
+-----------------------+-----------------------------------------------+
|
+-----------------------+-----------------------------------------------+
|
||||||
| Constant | Meaning |
|
| Constant | Meaning |
|
||||||
+=======================+===============================================+
|
+=======================+===============================================+
|
||||||
| :const:`EVENT_READ` | Available for read |
|
| .. data:: EVENT_READ | Available for read |
|
||||||
+-----------------------+-----------------------------------------------+
|
+-----------------------+-----------------------------------------------+
|
||||||
| :const:`EVENT_WRITE` | Available for write |
|
| .. data:: EVENT_WRITE | Available for write |
|
||||||
+-----------------------+-----------------------------------------------+
|
+-----------------------+-----------------------------------------------+
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,8 +132,8 @@ constants below:
|
||||||
|
|
||||||
Change a registered file object's monitored events or attached data.
|
Change a registered file object's monitored events or attached data.
|
||||||
|
|
||||||
This is equivalent to :meth:`BaseSelector.unregister(fileobj)` followed
|
This is equivalent to ``BaseSelector.unregister(fileobj)`` followed
|
||||||
by :meth:`BaseSelector.register(fileobj, events, data)`, except that it
|
by ``BaseSelector.register(fileobj, events, data)``, except that it
|
||||||
can be implemented more efficiently.
|
can be implemented more efficiently.
|
||||||
|
|
||||||
This returns a new :class:`SelectorKey` instance, or raises a
|
This returns a new :class:`SelectorKey` instance, or raises a
|
||||||
|
|
|
@ -369,7 +369,7 @@ Directory and files operations
|
||||||
If *copy_function* is given, it must be a callable that takes two arguments
|
If *copy_function* is given, it must be a callable that takes two arguments
|
||||||
*src* and *dst*, and will be used to copy *src* to *dst* if
|
*src* and *dst*, and will be used to copy *src* to *dst* if
|
||||||
:func:`os.rename` cannot be used. If the source is a directory,
|
:func:`os.rename` cannot be used. If the source is a directory,
|
||||||
:func:`copytree` is called, passing it the :func:`copy_function`. The
|
:func:`copytree` is called, passing it the *copy_function*. The
|
||||||
default *copy_function* is :func:`copy2`. Using :func:`~shutil.copy` as the
|
default *copy_function* is :func:`copy2`. Using :func:`~shutil.copy` as the
|
||||||
*copy_function* allows the move to succeed when it is not possible to also
|
*copy_function* allows the move to succeed when it is not possible to also
|
||||||
copy the metadata, at the expense of not copying any of the metadata.
|
copy the metadata, at the expense of not copying any of the metadata.
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
|
|
||||||
The :mod:`stat` module defines constants and functions for interpreting the
|
The :mod:`stat` module defines constants and functions for interpreting the
|
||||||
results of :func:`os.stat`, :func:`os.fstat` and :func:`os.lstat` (if they
|
results of :func:`os.stat`, :func:`os.fstat` and :func:`os.lstat` (if they
|
||||||
exist). For complete details about the :c:func:`stat`, :c:func:`fstat` and
|
exist). For complete details about the :c:func:`stat`, :c:func:`!fstat` and
|
||||||
:c:func:`lstat` calls, consult the documentation for your system.
|
:c:func:`!lstat` calls, consult the documentation for your system.
|
||||||
|
|
||||||
.. versionchanged:: 3.4
|
.. versionchanged:: 3.4
|
||||||
The stat module is backed by a C implementation.
|
The stat module is backed by a C implementation.
|
||||||
|
@ -89,9 +89,9 @@ mode:
|
||||||
.. function:: S_IFMT(mode)
|
.. function:: S_IFMT(mode)
|
||||||
|
|
||||||
Return the portion of the file's mode that describes the file type (used by the
|
Return the portion of the file's mode that describes the file type (used by the
|
||||||
:func:`S_IS\*` functions above).
|
:func:`!S_IS\*` functions above).
|
||||||
|
|
||||||
Normally, you would use the :func:`os.path.is\*` functions for testing the type
|
Normally, you would use the :func:`!os.path.is\*` functions for testing the type
|
||||||
of a file; the functions here are useful when you are doing multiple tests of
|
of a file; the functions here are useful when you are doing multiple tests of
|
||||||
the same file and wish to avoid the overhead of the :c:func:`stat` system call
|
the same file and wish to avoid the overhead of the :c:func:`stat` system call
|
||||||
for each test. These are also useful when checking for information about a file
|
for each test. These are also useful when checking for information about a file
|
||||||
|
|
|
@ -44,7 +44,7 @@ Any object can be tested for truth value, for use in an :keyword:`if` or
|
||||||
.. index:: single: true
|
.. index:: single: true
|
||||||
|
|
||||||
By default, an object is considered true unless its class defines either a
|
By default, an object is considered true unless its class defines either a
|
||||||
:meth:`__bool__` method that returns ``False`` or a :meth:`__len__` method that
|
:meth:`~object.__bool__` method that returns ``False`` or a :meth:`__len__` method that
|
||||||
returns zero, when called with the object. [1]_ Here are most of the built-in
|
returns zero, when called with the object. [1]_ Here are most of the built-in
|
||||||
objects considered false:
|
objects considered false:
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ Python uses an installation scheme that differs depending on the platform and on
|
||||||
the installation options. These schemes are stored in :mod:`sysconfig` under
|
the installation options. These schemes are stored in :mod:`sysconfig` under
|
||||||
unique identifiers based on the value returned by :const:`os.name`.
|
unique identifiers based on the value returned by :const:`os.name`.
|
||||||
|
|
||||||
Every new component that is installed using :mod:`distutils` or a
|
Every new component that is installed using :mod:`!distutils` or a
|
||||||
Distutils-based system will follow the same scheme to copy its file in the right
|
Distutils-based system will follow the same scheme to copy its file in the right
|
||||||
places.
|
places.
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ functions should be good enough; otherwise, you should use an instance of
|
||||||
First the whitespace in *text* is collapsed (all whitespace is replaced by
|
First the whitespace in *text* is collapsed (all whitespace is replaced by
|
||||||
single spaces). If the result fits in the *width*, it is returned.
|
single spaces). If the result fits in the *width*, it is returned.
|
||||||
Otherwise, enough words are dropped from the end so that the remaining words
|
Otherwise, enough words are dropped from the end so that the remaining words
|
||||||
plus the :attr:`placeholder` fit within :attr:`width`::
|
plus the :attr:`.placeholder` fit within :attr:`.width`::
|
||||||
|
|
||||||
>>> textwrap.shorten("Hello world!", width=12)
|
>>> textwrap.shorten("Hello world!", width=12)
|
||||||
'Hello world!'
|
'Hello world!'
|
||||||
|
@ -173,7 +173,7 @@ hyphenated words; only then will long words be broken if necessary, unless
|
||||||
.. attribute:: expand_tabs
|
.. attribute:: expand_tabs
|
||||||
|
|
||||||
(default: ``True``) If true, then all tab characters in *text* will be
|
(default: ``True``) If true, then all tab characters in *text* will be
|
||||||
expanded to spaces using the :meth:`expandtabs` method of *text*.
|
expanded to spaces using the :meth:`~str.expandtabs` method of *text*.
|
||||||
|
|
||||||
|
|
||||||
.. attribute:: tabsize
|
.. attribute:: tabsize
|
||||||
|
|
|
@ -72,6 +72,8 @@ The following exceptions are raised by :mod:`urllib.error` as appropriate:
|
||||||
This exception is raised when the :func:`~urllib.request.urlretrieve`
|
This exception is raised when the :func:`~urllib.request.urlretrieve`
|
||||||
function detects that
|
function detects that
|
||||||
the amount of the downloaded data is less than the expected amount (given by
|
the amount of the downloaded data is less than the expected amount (given by
|
||||||
the *Content-Length* header). The :attr:`content` attribute stores the
|
the *Content-Length* header).
|
||||||
downloaded (and supposedly truncated) data.
|
|
||||||
|
|
||||||
|
.. attribute:: content
|
||||||
|
|
||||||
|
The downloaded (and supposedly truncated) data.
|
||||||
|
|
|
@ -288,7 +288,7 @@ This module offers the following functions:
|
||||||
table (FAT) file system, the filename may not have an extension.
|
table (FAT) file system, the filename may not have an extension.
|
||||||
|
|
||||||
A call to :func:`LoadKey` fails if the calling process does not have the
|
A call to :func:`LoadKey` fails if the calling process does not have the
|
||||||
:const:`SE_RESTORE_PRIVILEGE` privilege. Note that privileges are different
|
:c:data:`!SE_RESTORE_PRIVILEGE` privilege. Note that privileges are different
|
||||||
from permissions -- see the `RegLoadKey documentation
|
from permissions -- see the `RegLoadKey documentation
|
||||||
<https://msdn.microsoft.com/en-us/library/ms724889%28v=VS.85%29.aspx>`__ for
|
<https://msdn.microsoft.com/en-us/library/ms724889%28v=VS.85%29.aspx>`__ for
|
||||||
more details.
|
more details.
|
||||||
|
@ -414,7 +414,7 @@ This module offers the following functions:
|
||||||
|
|
||||||
If *key* represents a key on a remote computer, the path described by
|
If *key* represents a key on a remote computer, the path described by
|
||||||
*file_name* is relative to the remote computer. The caller of this method must
|
*file_name* is relative to the remote computer. The caller of this method must
|
||||||
possess the :const:`SeBackupPrivilege` security privilege. Note that
|
possess the **SeBackupPrivilege** security privilege. Note that
|
||||||
privileges are different than permissions -- see the
|
privileges are different than permissions -- see the
|
||||||
`Conflicts Between User Rights and Permissions documentation
|
`Conflicts Between User Rights and Permissions documentation
|
||||||
<https://msdn.microsoft.com/en-us/library/ms724878%28v=VS.85%29.aspx>`__
|
<https://msdn.microsoft.com/en-us/library/ms724878%28v=VS.85%29.aspx>`__
|
||||||
|
@ -536,7 +536,7 @@ This module offers the following functions:
|
||||||
Constants
|
Constants
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
The following constants are defined for use in many :mod:`_winreg` functions.
|
The following constants are defined for use in many :mod:`winreg` functions.
|
||||||
|
|
||||||
.. _hkey-constants:
|
.. _hkey-constants:
|
||||||
|
|
||||||
|
@ -745,7 +745,7 @@ All registry functions in this module return one of these objects.
|
||||||
All registry functions in this module which accept a handle object also accept
|
All registry functions in this module which accept a handle object also accept
|
||||||
an integer, however, use of the handle object is encouraged.
|
an integer, however, use of the handle object is encouraged.
|
||||||
|
|
||||||
Handle objects provide semantics for :meth:`__bool__` -- thus ::
|
Handle objects provide semantics for :meth:`~object.__bool__` -- thus ::
|
||||||
|
|
||||||
if handle:
|
if handle:
|
||||||
print("Yes")
|
print("Yes")
|
||||||
|
|
|
@ -24,7 +24,7 @@ provided by Windows platforms. It includes functions and several constants.
|
||||||
|
|
||||||
.. function:: PlaySound(sound, flags)
|
.. function:: PlaySound(sound, flags)
|
||||||
|
|
||||||
Call the underlying :c:func:`PlaySound` function from the Platform API. The
|
Call the underlying :c:func:`!PlaySound` function from the Platform API. The
|
||||||
*sound* parameter may be a filename, a system sound alias, audio data as a
|
*sound* parameter may be a filename, a system sound alias, audio data as a
|
||||||
:term:`bytes-like object`, or ``None``. Its
|
:term:`bytes-like object`, or ``None``. Its
|
||||||
interpretation depends on the value of *flags*, which can be a bitwise ORed
|
interpretation depends on the value of *flags*, which can be a bitwise ORed
|
||||||
|
@ -35,7 +35,7 @@ provided by Windows platforms. It includes functions and several constants.
|
||||||
|
|
||||||
.. function:: MessageBeep(type=MB_OK)
|
.. function:: MessageBeep(type=MB_OK)
|
||||||
|
|
||||||
Call the underlying :c:func:`MessageBeep` function from the Platform API. This
|
Call the underlying :c:func:`!MessageBeep` function from the Platform API. This
|
||||||
plays a sound as specified in the registry. The *type* argument specifies which
|
plays a sound as specified in the registry. The *type* argument specifies which
|
||||||
sound to play; possible values are ``-1``, ``MB_ICONASTERISK``,
|
sound to play; possible values are ``-1``, ``MB_ICONASTERISK``,
|
||||||
``MB_ICONEXCLAMATION``, ``MB_ICONHAND``, ``MB_ICONQUESTION``, and ``MB_OK``, all
|
``MB_ICONEXCLAMATION``, ``MB_ICONHAND``, ``MB_ICONQUESTION``, and ``MB_OK``, all
|
||||||
|
|
|
@ -75,10 +75,10 @@ decompression bomb Safe Safe Safe
|
||||||
potential reliance on system-provided libraries. Check
|
potential reliance on system-provided libraries. Check
|
||||||
:const:`pyexpat.EXPAT_VERSION`.
|
:const:`pyexpat.EXPAT_VERSION`.
|
||||||
2. :mod:`xml.etree.ElementTree` doesn't expand external entities and raises a
|
2. :mod:`xml.etree.ElementTree` doesn't expand external entities and raises a
|
||||||
:exc:`ParserError` when an entity occurs.
|
:exc:`~xml.etree.ElementTree.ParseError` when an entity occurs.
|
||||||
3. :mod:`xml.dom.minidom` doesn't expand external entities and simply returns
|
3. :mod:`xml.dom.minidom` doesn't expand external entities and simply returns
|
||||||
the unexpanded entity verbatim.
|
the unexpanded entity verbatim.
|
||||||
4. :mod:`xmlrpclib` doesn't expand external entities and omits them.
|
4. :mod:`xmlrpc.client` doesn't expand external entities and omits them.
|
||||||
5. Since Python 3.7.1, external general entities are no longer processed by
|
5. Since Python 3.7.1, external general entities are no longer processed by
|
||||||
default.
|
default.
|
||||||
|
|
||||||
|
@ -119,8 +119,8 @@ all known attack vectors with examples and references.
|
||||||
|
|
||||||
.. _defusedxml-package:
|
.. _defusedxml-package:
|
||||||
|
|
||||||
The :mod:`defusedxml` Package
|
The :mod:`!defusedxml` Package
|
||||||
------------------------------------------------------
|
------------------------------
|
||||||
|
|
||||||
`defusedxml`_ is a pure Python package with modified subclasses of all stdlib
|
`defusedxml`_ is a pure Python package with modified subclasses of all stdlib
|
||||||
XML parsers that prevent any potentially malicious operation. Use of this
|
XML parsers that prevent any potentially malicious operation. Use of this
|
||||||
|
|
|
@ -393,7 +393,7 @@ implements this interface, then register the object with your
|
||||||
:class:`~xml.sax.xmlreader.XMLReader`, the parser
|
:class:`~xml.sax.xmlreader.XMLReader`, the parser
|
||||||
will call the methods in your object to report all warnings and errors. There
|
will call the methods in your object to report all warnings and errors. There
|
||||||
are three levels of errors available: warnings, (possibly) recoverable errors,
|
are three levels of errors available: warnings, (possibly) recoverable errors,
|
||||||
and unrecoverable errors. All methods take a :exc:`SAXParseException` as the
|
and unrecoverable errors. All methods take a :exc:`~xml.sax.SAXParseException` as the
|
||||||
only parameter. Errors and warnings may be converted to an exception by raising
|
only parameter. Errors and warnings may be converted to an exception by raising
|
||||||
the passed-in exception object.
|
the passed-in exception object.
|
||||||
|
|
||||||
|
|
|
@ -92,5 +92,5 @@ or as base classes.
|
||||||
reading. The input source can be given as a string, a file-like object, or
|
reading. The input source can be given as a string, a file-like object, or
|
||||||
an :class:`~xml.sax.xmlreader.InputSource` object; parsers will use this
|
an :class:`~xml.sax.xmlreader.InputSource` object; parsers will use this
|
||||||
function to implement the polymorphic *source* argument to their
|
function to implement the polymorphic *source* argument to their
|
||||||
:meth:`parse` method.
|
:meth:`~xml.sax.xmlreader.XMLReader.parse` method.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
:mod:`xmlrpc` --- XMLRPC server and client modules
|
:mod:`!xmlrpc` --- XMLRPC server and client modules
|
||||||
==================================================
|
===================================================
|
||||||
|
|
||||||
XML-RPC is a Remote Procedure Call method that uses XML passed via HTTP as a
|
XML-RPC is a Remote Procedure Call method that uses XML passed via HTTP as a
|
||||||
transport. With it, a client can call methods with parameters on a remote
|
transport. With it, a client can call methods with parameters on a remote
|
||||||
|
|
|
@ -1594,9 +1594,9 @@ Basic customization
|
||||||
|
|
||||||
Called to implement truth value testing and the built-in operation
|
Called to implement truth value testing and the built-in operation
|
||||||
``bool()``; should return ``False`` or ``True``. When this method is not
|
``bool()``; should return ``False`` or ``True``. When this method is not
|
||||||
defined, :meth:`__len__` is called, if it is defined, and the object is
|
defined, :meth:`~object.__len__` is called, if it is defined, and the object is
|
||||||
considered true if its result is nonzero. If a class defines neither
|
considered true if its result is nonzero. If a class defines neither
|
||||||
:meth:`__len__` nor :meth:`__bool__`, all its instances are considered
|
:meth:`!__len__` nor :meth:`!__bool__`, all its instances are considered
|
||||||
true.
|
true.
|
||||||
|
|
||||||
|
|
||||||
|
@ -2494,7 +2494,7 @@ through the object's keys; for sequences, it should iterate through the values.
|
||||||
|
|
||||||
Called to implement the built-in function :func:`len`. Should return the length
|
Called to implement the built-in function :func:`len`. Should return the length
|
||||||
of the object, an integer ``>=`` 0. Also, an object that doesn't define a
|
of the object, an integer ``>=`` 0. Also, an object that doesn't define a
|
||||||
:meth:`__bool__` method and whose :meth:`__len__` method returns zero is
|
:meth:`~object.__bool__` method and whose :meth:`!__len__` method returns zero is
|
||||||
considered to be false in a Boolean context.
|
considered to be false in a Boolean context.
|
||||||
|
|
||||||
.. impl-detail::
|
.. impl-detail::
|
||||||
|
@ -2503,7 +2503,7 @@ through the object's keys; for sequences, it should iterate through the values.
|
||||||
If the length is larger than :data:`!sys.maxsize` some features (such as
|
If the length is larger than :data:`!sys.maxsize` some features (such as
|
||||||
:func:`len`) may raise :exc:`OverflowError`. To prevent raising
|
:func:`len`) may raise :exc:`OverflowError`. To prevent raising
|
||||||
:exc:`!OverflowError` by truth value testing, an object must define a
|
:exc:`!OverflowError` by truth value testing, an object must define a
|
||||||
:meth:`__bool__` method.
|
:meth:`~object.__bool__` method.
|
||||||
|
|
||||||
|
|
||||||
.. method:: object.__length_hint__(self)
|
.. method:: object.__length_hint__(self)
|
||||||
|
|
|
@ -1717,7 +1717,7 @@ control flow statements, the following values are interpreted as false:
|
||||||
``False``, ``None``, numeric zero of all types, and empty strings and containers
|
``False``, ``None``, numeric zero of all types, and empty strings and containers
|
||||||
(including strings, tuples, lists, dictionaries, sets and frozensets). All
|
(including strings, tuples, lists, dictionaries, sets and frozensets). All
|
||||||
other values are interpreted as true. User-defined objects can customize their
|
other values are interpreted as true. User-defined objects can customize their
|
||||||
truth value by providing a :meth:`__bool__` method.
|
truth value by providing a :meth:`~object.__bool__` method.
|
||||||
|
|
||||||
.. index:: pair: operator; not
|
.. index:: pair: operator; not
|
||||||
|
|
||||||
|
|
|
@ -787,7 +787,7 @@ is converted before formatting. Conversion ``'!s'`` calls :func:`str` on
|
||||||
the result, ``'!r'`` calls :func:`repr`, and ``'!a'`` calls :func:`ascii`.
|
the result, ``'!r'`` calls :func:`repr`, and ``'!a'`` calls :func:`ascii`.
|
||||||
|
|
||||||
The result is then formatted using the :func:`format` protocol. The
|
The result is then formatted using the :func:`format` protocol. The
|
||||||
format specifier is passed to the :meth:`__format__` method of the
|
format specifier is passed to the :meth:`~object.__format__` method of the
|
||||||
expression or conversion result. An empty string is passed when the
|
expression or conversion result. An empty string is passed when the
|
||||||
format specifier is omitted. The formatted result is then included in
|
format specifier is omitted. The formatted result is then included in
|
||||||
the final value of the whole string.
|
the final value of the whole string.
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
# to help avoid merge conflicts.
|
# to help avoid merge conflicts.
|
||||||
|
|
||||||
Doc/c-api/arg.rst
|
Doc/c-api/arg.rst
|
||||||
Doc/c-api/bool.rst
|
|
||||||
Doc/c-api/buffer.rst
|
Doc/c-api/buffer.rst
|
||||||
Doc/c-api/datetime.rst
|
Doc/c-api/datetime.rst
|
||||||
Doc/c-api/descriptor.rst
|
Doc/c-api/descriptor.rst
|
||||||
|
@ -31,19 +30,16 @@ Doc/c-api/unicode.rst
|
||||||
Doc/extending/extending.rst
|
Doc/extending/extending.rst
|
||||||
Doc/extending/newtypes.rst
|
Doc/extending/newtypes.rst
|
||||||
Doc/faq/design.rst
|
Doc/faq/design.rst
|
||||||
Doc/faq/extending.rst
|
|
||||||
Doc/faq/gui.rst
|
Doc/faq/gui.rst
|
||||||
Doc/faq/library.rst
|
Doc/faq/library.rst
|
||||||
Doc/faq/programming.rst
|
Doc/faq/programming.rst
|
||||||
Doc/glossary.rst
|
Doc/glossary.rst
|
||||||
Doc/howto/curses.rst
|
|
||||||
Doc/howto/descriptor.rst
|
Doc/howto/descriptor.rst
|
||||||
Doc/howto/enum.rst
|
Doc/howto/enum.rst
|
||||||
Doc/howto/isolating-extensions.rst
|
Doc/howto/isolating-extensions.rst
|
||||||
Doc/howto/logging-cookbook.rst
|
Doc/howto/logging-cookbook.rst
|
||||||
Doc/howto/logging.rst
|
Doc/howto/logging.rst
|
||||||
Doc/howto/urllib2.rst
|
Doc/howto/urllib2.rst
|
||||||
Doc/install/index.rst
|
|
||||||
Doc/library/2to3.rst
|
Doc/library/2to3.rst
|
||||||
Doc/library/__future__.rst
|
Doc/library/__future__.rst
|
||||||
Doc/library/abc.rst
|
Doc/library/abc.rst
|
||||||
|
@ -52,7 +48,6 @@ Doc/library/ast.rst
|
||||||
Doc/library/asyncio-dev.rst
|
Doc/library/asyncio-dev.rst
|
||||||
Doc/library/asyncio-eventloop.rst
|
Doc/library/asyncio-eventloop.rst
|
||||||
Doc/library/asyncio-extending.rst
|
Doc/library/asyncio-extending.rst
|
||||||
Doc/library/asyncio-future.rst
|
|
||||||
Doc/library/asyncio-policy.rst
|
Doc/library/asyncio-policy.rst
|
||||||
Doc/library/asyncio-stream.rst
|
Doc/library/asyncio-stream.rst
|
||||||
Doc/library/asyncio-subprocess.rst
|
Doc/library/asyncio-subprocess.rst
|
||||||
|
@ -66,12 +61,10 @@ Doc/library/cgi.rst
|
||||||
Doc/library/chunk.rst
|
Doc/library/chunk.rst
|
||||||
Doc/library/cmath.rst
|
Doc/library/cmath.rst
|
||||||
Doc/library/cmd.rst
|
Doc/library/cmd.rst
|
||||||
Doc/library/code.rst
|
|
||||||
Doc/library/codecs.rst
|
Doc/library/codecs.rst
|
||||||
Doc/library/collections.abc.rst
|
Doc/library/collections.abc.rst
|
||||||
Doc/library/collections.rst
|
Doc/library/collections.rst
|
||||||
Doc/library/concurrent.futures.rst
|
Doc/library/concurrent.futures.rst
|
||||||
Doc/library/concurrent.rst
|
|
||||||
Doc/library/configparser.rst
|
Doc/library/configparser.rst
|
||||||
Doc/library/contextlib.rst
|
Doc/library/contextlib.rst
|
||||||
Doc/library/copy.rst
|
Doc/library/copy.rst
|
||||||
|
@ -86,11 +79,8 @@ Doc/library/dis.rst
|
||||||
Doc/library/doctest.rst
|
Doc/library/doctest.rst
|
||||||
Doc/library/email.charset.rst
|
Doc/library/email.charset.rst
|
||||||
Doc/library/email.compat32-message.rst
|
Doc/library/email.compat32-message.rst
|
||||||
Doc/library/email.encoders.rst
|
|
||||||
Doc/library/email.errors.rst
|
Doc/library/email.errors.rst
|
||||||
Doc/library/email.generator.rst
|
|
||||||
Doc/library/email.headerregistry.rst
|
Doc/library/email.headerregistry.rst
|
||||||
Doc/library/email.message.rst
|
|
||||||
Doc/library/email.mime.rst
|
Doc/library/email.mime.rst
|
||||||
Doc/library/email.parser.rst
|
Doc/library/email.parser.rst
|
||||||
Doc/library/email.policy.rst
|
Doc/library/email.policy.rst
|
||||||
|
@ -98,27 +88,21 @@ Doc/library/enum.rst
|
||||||
Doc/library/exceptions.rst
|
Doc/library/exceptions.rst
|
||||||
Doc/library/faulthandler.rst
|
Doc/library/faulthandler.rst
|
||||||
Doc/library/fcntl.rst
|
Doc/library/fcntl.rst
|
||||||
Doc/library/filecmp.rst
|
|
||||||
Doc/library/fileinput.rst
|
|
||||||
Doc/library/ftplib.rst
|
Doc/library/ftplib.rst
|
||||||
Doc/library/functions.rst
|
Doc/library/functions.rst
|
||||||
Doc/library/functools.rst
|
Doc/library/functools.rst
|
||||||
Doc/library/getopt.rst
|
Doc/library/getopt.rst
|
||||||
Doc/library/getpass.rst
|
Doc/library/getpass.rst
|
||||||
Doc/library/gettext.rst
|
Doc/library/gettext.rst
|
||||||
Doc/library/graphlib.rst
|
|
||||||
Doc/library/gzip.rst
|
Doc/library/gzip.rst
|
||||||
Doc/library/hashlib.rst
|
|
||||||
Doc/library/http.client.rst
|
Doc/library/http.client.rst
|
||||||
Doc/library/http.cookiejar.rst
|
Doc/library/http.cookiejar.rst
|
||||||
Doc/library/http.cookies.rst
|
Doc/library/http.cookies.rst
|
||||||
Doc/library/http.server.rst
|
Doc/library/http.server.rst
|
||||||
Doc/library/importlib.resources.abc.rst
|
|
||||||
Doc/library/importlib.resources.rst
|
Doc/library/importlib.resources.rst
|
||||||
Doc/library/importlib.rst
|
Doc/library/importlib.rst
|
||||||
Doc/library/inspect.rst
|
Doc/library/inspect.rst
|
||||||
Doc/library/io.rst
|
Doc/library/io.rst
|
||||||
Doc/library/json.rst
|
|
||||||
Doc/library/locale.rst
|
Doc/library/locale.rst
|
||||||
Doc/library/logging.config.rst
|
Doc/library/logging.config.rst
|
||||||
Doc/library/logging.handlers.rst
|
Doc/library/logging.handlers.rst
|
||||||
|
@ -127,13 +111,10 @@ Doc/library/lzma.rst
|
||||||
Doc/library/mailbox.rst
|
Doc/library/mailbox.rst
|
||||||
Doc/library/mmap.rst
|
Doc/library/mmap.rst
|
||||||
Doc/library/msilib.rst
|
Doc/library/msilib.rst
|
||||||
Doc/library/msvcrt.rst
|
|
||||||
Doc/library/multiprocessing.rst
|
Doc/library/multiprocessing.rst
|
||||||
Doc/library/multiprocessing.shared_memory.rst
|
Doc/library/multiprocessing.shared_memory.rst
|
||||||
Doc/library/netrc.rst
|
|
||||||
Doc/library/nntplib.rst
|
Doc/library/nntplib.rst
|
||||||
Doc/library/numbers.rst
|
Doc/library/numbers.rst
|
||||||
Doc/library/operator.rst
|
|
||||||
Doc/library/optparse.rst
|
Doc/library/optparse.rst
|
||||||
Doc/library/os.path.rst
|
Doc/library/os.path.rst
|
||||||
Doc/library/os.rst
|
Doc/library/os.rst
|
||||||
|
@ -142,10 +123,7 @@ Doc/library/pickle.rst
|
||||||
Doc/library/pickletools.rst
|
Doc/library/pickletools.rst
|
||||||
Doc/library/platform.rst
|
Doc/library/platform.rst
|
||||||
Doc/library/plistlib.rst
|
Doc/library/plistlib.rst
|
||||||
Doc/library/poplib.rst
|
|
||||||
Doc/library/pprint.rst
|
|
||||||
Doc/library/profile.rst
|
Doc/library/profile.rst
|
||||||
Doc/library/pty.rst
|
|
||||||
Doc/library/pyclbr.rst
|
Doc/library/pyclbr.rst
|
||||||
Doc/library/pydoc.rst
|
Doc/library/pydoc.rst
|
||||||
Doc/library/pyexpat.rst
|
Doc/library/pyexpat.rst
|
||||||
|
@ -154,32 +132,27 @@ Doc/library/readline.rst
|
||||||
Doc/library/reprlib.rst
|
Doc/library/reprlib.rst
|
||||||
Doc/library/resource.rst
|
Doc/library/resource.rst
|
||||||
Doc/library/rlcompleter.rst
|
Doc/library/rlcompleter.rst
|
||||||
Doc/library/sched.rst
|
|
||||||
Doc/library/select.rst
|
Doc/library/select.rst
|
||||||
Doc/library/selectors.rst
|
Doc/library/selectors.rst
|
||||||
Doc/library/shelve.rst
|
Doc/library/shelve.rst
|
||||||
Doc/library/shutil.rst
|
|
||||||
Doc/library/signal.rst
|
Doc/library/signal.rst
|
||||||
Doc/library/site.rst
|
Doc/library/site.rst
|
||||||
Doc/library/smtplib.rst
|
Doc/library/smtplib.rst
|
||||||
Doc/library/socket.rst
|
Doc/library/socket.rst
|
||||||
Doc/library/socketserver.rst
|
Doc/library/socketserver.rst
|
||||||
Doc/library/ssl.rst
|
Doc/library/ssl.rst
|
||||||
Doc/library/stat.rst
|
|
||||||
Doc/library/stdtypes.rst
|
Doc/library/stdtypes.rst
|
||||||
Doc/library/string.rst
|
Doc/library/string.rst
|
||||||
Doc/library/subprocess.rst
|
Doc/library/subprocess.rst
|
||||||
Doc/library/sunau.rst
|
Doc/library/sunau.rst
|
||||||
Doc/library/sys.rst
|
Doc/library/sys.rst
|
||||||
Doc/library/sys_path_init.rst
|
Doc/library/sys_path_init.rst
|
||||||
Doc/library/sysconfig.rst
|
|
||||||
Doc/library/syslog.rst
|
Doc/library/syslog.rst
|
||||||
Doc/library/tarfile.rst
|
Doc/library/tarfile.rst
|
||||||
Doc/library/telnetlib.rst
|
Doc/library/telnetlib.rst
|
||||||
Doc/library/tempfile.rst
|
Doc/library/tempfile.rst
|
||||||
Doc/library/termios.rst
|
Doc/library/termios.rst
|
||||||
Doc/library/test.rst
|
Doc/library/test.rst
|
||||||
Doc/library/textwrap.rst
|
|
||||||
Doc/library/threading.rst
|
Doc/library/threading.rst
|
||||||
Doc/library/time.rst
|
Doc/library/time.rst
|
||||||
Doc/library/tkinter.rst
|
Doc/library/tkinter.rst
|
||||||
|
@ -192,14 +165,11 @@ Doc/library/turtle.rst
|
||||||
Doc/library/unittest.mock-examples.rst
|
Doc/library/unittest.mock-examples.rst
|
||||||
Doc/library/unittest.mock.rst
|
Doc/library/unittest.mock.rst
|
||||||
Doc/library/unittest.rst
|
Doc/library/unittest.rst
|
||||||
Doc/library/urllib.error.rst
|
|
||||||
Doc/library/urllib.parse.rst
|
Doc/library/urllib.parse.rst
|
||||||
Doc/library/urllib.request.rst
|
Doc/library/urllib.request.rst
|
||||||
Doc/library/uuid.rst
|
Doc/library/uuid.rst
|
||||||
Doc/library/weakref.rst
|
Doc/library/weakref.rst
|
||||||
Doc/library/webbrowser.rst
|
Doc/library/webbrowser.rst
|
||||||
Doc/library/winreg.rst
|
|
||||||
Doc/library/winsound.rst
|
|
||||||
Doc/library/wsgiref.rst
|
Doc/library/wsgiref.rst
|
||||||
Doc/library/xdrlib.rst
|
Doc/library/xdrlib.rst
|
||||||
Doc/library/xml.dom.minidom.rst
|
Doc/library/xml.dom.minidom.rst
|
||||||
|
@ -210,9 +180,7 @@ Doc/library/xml.rst
|
||||||
Doc/library/xml.sax.handler.rst
|
Doc/library/xml.sax.handler.rst
|
||||||
Doc/library/xml.sax.reader.rst
|
Doc/library/xml.sax.reader.rst
|
||||||
Doc/library/xml.sax.rst
|
Doc/library/xml.sax.rst
|
||||||
Doc/library/xml.sax.utils.rst
|
|
||||||
Doc/library/xmlrpc.client.rst
|
Doc/library/xmlrpc.client.rst
|
||||||
Doc/library/xmlrpc.rst
|
|
||||||
Doc/library/xmlrpc.server.rst
|
Doc/library/xmlrpc.server.rst
|
||||||
Doc/library/zlib.rst
|
Doc/library/zlib.rst
|
||||||
Doc/license.rst
|
Doc/license.rst
|
||||||
|
@ -220,18 +188,14 @@ Doc/reference/compound_stmts.rst
|
||||||
Doc/reference/datamodel.rst
|
Doc/reference/datamodel.rst
|
||||||
Doc/reference/expressions.rst
|
Doc/reference/expressions.rst
|
||||||
Doc/reference/import.rst
|
Doc/reference/import.rst
|
||||||
Doc/reference/lexical_analysis.rst
|
|
||||||
Doc/reference/simple_stmts.rst
|
Doc/reference/simple_stmts.rst
|
||||||
Doc/tutorial/appendix.rst
|
Doc/tutorial/appendix.rst
|
||||||
Doc/tutorial/classes.rst
|
Doc/tutorial/classes.rst
|
||||||
Doc/tutorial/controlflow.rst
|
Doc/tutorial/controlflow.rst
|
||||||
Doc/tutorial/datastructures.rst
|
Doc/tutorial/datastructures.rst
|
||||||
Doc/tutorial/errors.rst
|
|
||||||
Doc/tutorial/inputoutput.rst
|
Doc/tutorial/inputoutput.rst
|
||||||
Doc/tutorial/interactive.rst
|
|
||||||
Doc/tutorial/introduction.rst
|
Doc/tutorial/introduction.rst
|
||||||
Doc/tutorial/modules.rst
|
Doc/tutorial/modules.rst
|
||||||
Doc/tutorial/stdlib2.rst
|
|
||||||
Doc/using/cmdline.rst
|
Doc/using/cmdline.rst
|
||||||
Doc/using/configure.rst
|
Doc/using/configure.rst
|
||||||
Doc/using/windows.rst
|
Doc/using/windows.rst
|
||||||
|
|
|
@ -154,7 +154,7 @@ exception type.
|
||||||
The *except clause* may specify a variable after the exception name. The
|
The *except clause* may specify a variable after the exception name. The
|
||||||
variable is bound to the exception instance which typically has an ``args``
|
variable is bound to the exception instance which typically has an ``args``
|
||||||
attribute that stores the arguments. For convenience, builtin exception
|
attribute that stores the arguments. For convenience, builtin exception
|
||||||
types define :meth:`__str__` to print all the arguments without explicitly
|
types define :meth:`~object.__str__` to print all the arguments without explicitly
|
||||||
accessing ``.args``. ::
|
accessing ``.args``. ::
|
||||||
|
|
||||||
>>> try:
|
>>> try:
|
||||||
|
@ -174,7 +174,7 @@ accessing ``.args``. ::
|
||||||
x = spam
|
x = spam
|
||||||
y = eggs
|
y = eggs
|
||||||
|
|
||||||
The exception's :meth:`__str__` output is printed as the last part ('detail')
|
The exception's :meth:`~object.__str__` output is printed as the last part ('detail')
|
||||||
of the message for unhandled exceptions.
|
of the message for unhandled exceptions.
|
||||||
|
|
||||||
:exc:`BaseException` is the common base class of all exceptions. One of its
|
:exc:`BaseException` is the common base class of all exceptions. One of its
|
||||||
|
|
|
@ -23,7 +23,7 @@ Python statement names, the current local variables, and the available
|
||||||
module names. For dotted expressions such as ``string.a``, it will evaluate
|
module names. For dotted expressions such as ``string.a``, it will evaluate
|
||||||
the expression up to the final ``'.'`` and then suggest completions from
|
the expression up to the final ``'.'`` and then suggest completions from
|
||||||
the attributes of the resulting object. Note that this may execute
|
the attributes of the resulting object. Note that this may execute
|
||||||
application-defined code if an object with a :meth:`__getattr__` method
|
application-defined code if an object with a :meth:`~object.__getattr__` method
|
||||||
is part of the expression. The default configuration also saves your
|
is part of the expression. The default configuration also saves your
|
||||||
history into a file named :file:`.python_history` in your user directory.
|
history into a file named :file:`.python_history` in your user directory.
|
||||||
The history will be available again during the next interactive interpreter
|
The history will be available again during the next interactive interpreter
|
||||||
|
|
|
@ -789,7 +789,7 @@ Operators And Special Methods
|
||||||
:attr:`__doc__`, :attr:`__globals__`, :attr:`~definition.__name__`,
|
:attr:`__doc__`, :attr:`__globals__`, :attr:`~definition.__name__`,
|
||||||
respectively.
|
respectively.
|
||||||
|
|
||||||
* :meth:`__nonzero__` is now :meth:`__bool__`.
|
* :meth:`!__nonzero__` is now :meth:`~object.__bool__`.
|
||||||
|
|
||||||
Builtins
|
Builtins
|
||||||
--------
|
--------
|
||||||
|
|
|
@ -352,7 +352,7 @@ rather than ``JUMP_FORWARD`` with an argument of ``(2**32)+offset``.
|
||||||
.. nonce: 3Z_qxd
|
.. nonce: 3Z_qxd
|
||||||
.. section: Core and Builtins
|
.. section: Core and Builtins
|
||||||
|
|
||||||
Correct the docstring for the :meth:`__bool__` method. Patch by Jelle
|
Correct the docstring for the :meth:`~object.__bool__` method. Patch by Jelle
|
||||||
Zijlstra.
|
Zijlstra.
|
||||||
|
|
||||||
..
|
..
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue