Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[3.11] gh-101100: Fix most Sphinx nitpicks in the glossary andstdtypes.rst (GH-112757)#112790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-101100: Fix most Sphinx nitpicks in the glossary andstdtypes.rst (
GH-112757)(cherry picked from commite3f670e)Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
  • Loading branch information
@AlexWaygood@miss-islington
AlexWaygood authored andmiss-islington committedDec 6, 2023
commitfb8f89c210006d0caf957d724e396580492871da
47 changes: 26 additions & 21 deletionsDoc/glossary.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -160,9 +160,9 @@ Glossary
A :term:`file object` able to read and write
:term:`bytes-like objects <bytes-like object>`.
Examples of binary files are files opened in binary mode (``'rb'``,
``'wb'`` or ``'rb+'``), :data:`sys.stdin.buffer`,
:data:`sys.stdout.buffer`, and instances of :class:`io.BytesIO` and
:class:`gzip.GzipFile`.
``'wb'`` or ``'rb+'``), :data:`sys.stdin.buffer <sys.stdin>`,
:data:`sys.stdout.buffer <sys.stdout>`, and instances of
:class:`io.BytesIO` and :class:`gzip.GzipFile`.

See also :term:`text file` for a file object able to read and write
:class:`str` objects.
Expand DownExpand Up@@ -313,8 +313,9 @@ Glossary
:ref:`class definitions <class>` for more about decorators.

descriptor
Any object which defines the methods :meth:`__get__`, :meth:`__set__`, or
:meth:`__delete__`. When a class attribute is a descriptor, its special
Any object which defines the methods :meth:`~object.__get__`,
:meth:`~object.__set__`, or :meth:`~object.__delete__`.
When a class attribute is a descriptor, its special
binding behavior is triggered upon attribute lookup. Normally, using
*a.b* to get, set or delete an attribute looks up the object named *b* in
the class dictionary for *a*, but if *b* is a descriptor, the respective
Expand All@@ -328,7 +329,8 @@ Glossary

dictionary
An associative array, where arbitrary keys are mapped to values. The
keys can be any object with :meth:`__hash__` and :meth:`__eq__` methods.
keys can be any object with :meth:`~object.__hash__` and
:meth:`~object.__eq__` methods.
Called a hash in Perl.

dictionary comprehension
Expand DownExpand Up@@ -392,7 +394,7 @@ Glossary

file object
An object exposing a file-oriented API (with methods such as
:meth:`read()` or :meth:`write()`) to an underlying resource. Depending
:meth:`!read` or :meth:`!write`) to an underlying resource. Depending
on the way it was created, a file object can mediate access to a real
on-disk file or to another type of storage or communication device
(for example standard input/output, in-memory buffers, sockets, pipes,
Expand DownExpand Up@@ -568,8 +570,9 @@ Glossary

hashable
An object is *hashable* if it has a hash value which never changes during
its lifetime (it needs a :meth:`__hash__` method), and can be compared to
other objects (it needs an :meth:`__eq__` method). Hashable objects which
its lifetime (it needs a :meth:`~object.__hash__` method), and can be
compared to other objects (it needs an :meth:`~object.__eq__` method).
Hashable objects which
compare equal must have the same hash value.

Hashability makes an object usable as a dictionary key and a set member,
Expand DownExpand Up@@ -645,7 +648,8 @@ Glossary
iterables include all sequence types (such as :class:`list`, :class:`str`,
and :class:`tuple`) and some non-sequence types like :class:`dict`,
:term:`file objects <file object>`, and objects of any classes you define
with an :meth:`__iter__` method or with a :meth:`~object.__getitem__` method
with an :meth:`~iterator.__iter__` method or with a
:meth:`~object.__getitem__` method
that implements :term:`sequence` semantics.

Iterables can be
Expand All@@ -654,7 +658,7 @@ Glossary
as an argument to the built-in function :func:`iter`, it returns an
iterator for the object. This iterator is good for one pass over the set
of values. When using iterables, it is usually not necessary to call
:func:`iter` or deal with iterator objects yourself. The``for``
:func:`iter` or deal with iterator objects yourself. The:keyword:`for`
statement does that automatically for you, creating a temporary unnamed
variable to hold the iterator for the duration of the loop. See also
:term:`iterator`, :term:`sequence`, and :term:`generator`.
Expand All@@ -665,8 +669,8 @@ Glossary
:func:`next`) return successive items in the stream. When no more data
are available a :exc:`StopIteration` exception is raised instead. At this
point, the iterator object is exhausted and any further calls to its
:meth:`__next__` method just raise :exc:`StopIteration` again. Iterators
are required to have an :meth:`__iter__` method that returns the iterator
:meth:`!__next__` method just raise :exc:`StopIteration` again. Iterators
are required to have an :meth:`~iterator.__iter__` method that returns the iterator
object itself so every iterator is also iterable and may be used in most
places where other iterables are accepted. One notable exception is code
which attempts multiple iteration passes. A container object (such as a
Expand All@@ -680,7 +684,7 @@ Glossary
.. impl-detail::

CPython does not consistently apply the requirement that an iterator
define :meth:`__iter__`.
define :meth:`~iterator.__iter__`.

key function
A key function or collation function is a callable that returns a value
Expand DownExpand Up@@ -874,7 +878,8 @@ Glossary
Old name for the flavor of classes now used for all class objects. In
earlier Python versions, only new-style classes could use Python's newer,
versatile features like :attr:`~object.__slots__`, descriptors,
properties, :meth:`__getattribute__`, class methods, and static methods.
properties, :meth:`~object.__getattribute__`, class methods, and static
methods.

object
Any data with state (attributes or value) and defined behavior
Expand DownExpand Up@@ -954,7 +959,7 @@ Glossary
finders implement.

path entry hook
A callable on the :data:`sys.path_hook` list which returns a :term:`path
A callable on the :data:`sys.path_hooks` list which returns a :term:`path
entry finder` if it knows how to find modules on a specific :term:`path
entry`.

Expand DownExpand Up@@ -1086,18 +1091,18 @@ Glossary
sequence
An :term:`iterable` which supports efficient element access using integer
indices via the :meth:`~object.__getitem__` special method and defines a
:meth:`__len__` method that returns the length of the sequence.
:meth:`~object.__len__` method that returns the length of the sequence.
Some built-in sequence types are :class:`list`, :class:`str`,
:class:`tuple`, and :class:`bytes`. Note that :class:`dict` also
supports :meth:`~object.__getitem__` and :meth:`__len__`, but is considered a
supports :meth:`~object.__getitem__` and :meth:`!__len__`, but is considered a
mapping rather than a sequence because the lookups use arbitrary
:term:`immutable` keys rather than integers.

The :class:`collections.abc.Sequence` abstract base class
defines a much richer interface that goes beyond just
:meth:`~object.__getitem__` and :meth:`__len__`, adding :meth:`count`,
:meth:`index`, :meth:`__contains__`, and
:meth:`__reversed__`. Types that implement this expanded
:meth:`~object.__getitem__` and :meth:`~object.__len__`, adding
:meth:`count`, :meth:`index`, :meth:`~object.__contains__`, and
:meth:`~object.__reversed__`. Types that implement this expanded
interface can be registered explicitly using
:func:`~abc.ABCMeta.register`.

Expand Down
26 changes: 15 additions & 11 deletionsDoc/library/stdtypes.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,7 +44,8 @@ Any object can be tested for truth value, for use in an :keyword:`if` or
.. index:: single: true

By default, an object is considered true unless its class defines either a
:meth:`~object.__bool__` method that returns ``False`` or a :meth:`__len__` method that
:meth:`~object.__bool__` method that returns ``False`` or a
:meth:`~object.__len__` method that
returns zero, when called with the object. [1]_ Here are most of the built-in
objects considered false:

Expand DownExpand Up@@ -197,7 +198,7 @@ exception.

Two more operations with the same syntactic priority, :keyword:`in` and
:keyword:`not in`, are supported by types that are :term:`iterable` or
implement the :meth:`__contains__` method.
implement the :meth:`~object.__contains__` method.

.. _typesnumeric:

Expand DownExpand Up@@ -711,7 +712,7 @@ that's defined for any rational number, and hence applies to all instances of
:class:`int` and :class:`fractions.Fraction`, and all finite instances of
:class:`float` and :class:`decimal.Decimal`. Essentially, this function is
given by reduction modulo ``P`` for a fixed prime ``P``. The value of ``P`` is
made available to Python as the :attr:`modulus` attribute of
made available to Python as the :attr:`~sys.hash_info.modulus` attribute of
:data:`sys.hash_info`.

.. impl-detail::
Expand DownExpand Up@@ -866,9 +867,9 @@ Generator Types
---------------

Python's :term:`generator`\s provide a convenient way to implement the iterator
protocol. If a container object's :meth:`__iter__` method is implemented as a
protocol. If a container object's :meth:`~iterator.__iter__` method is implemented as a
generator, it will automatically return an iterator object (technically, a
generator object) supplying the :meth:`__iter__` and :meth:`~generator.__next__`
generator object) supplying the :meth:`!__iter__` and :meth:`~generator.__next__`
methods.
More information about generators can be found in :ref:`the documentation for
the yield expression <yieldexpr>`.
Expand DownExpand Up@@ -3624,7 +3625,7 @@ The conversion types are:
+------------+-----------------------------------------------------+-------+
| ``'b'`` | Bytes (any object that follows the | \(5) |
| | :ref:`buffer protocol <bufferobjects>` or has | |
| | :meth:`__bytes__`). | |
| | :meth:`~object.__bytes__`). | |
+------------+-----------------------------------------------------+-------+
| ``'s'`` | ``'s'`` is an alias for ``'b'`` and should only | \(6) |
| | be used for Python2/3 code bases. | |
Expand DownExpand Up@@ -4359,7 +4360,8 @@ The constructors for both classes work the same:
:meth:`symmetric_difference_update` methods will accept any iterable as an
argument.

Note, the *elem* argument to the :meth:`__contains__`, :meth:`remove`, and
Note, the *elem* argument to the :meth:`~object.__contains__`,
:meth:`remove`, and
:meth:`discard` methods may be a set. To support searching for an equivalent
frozenset, a temporary one is created from *elem*.

Expand DownExpand Up@@ -5178,9 +5180,11 @@ instantiated from the type::
TypeError: cannot create 'types.UnionType' instances

.. note::
The :meth:`__or__` method for type objects was added to support the syntax
``X | Y``. If a metaclass implements :meth:`__or__`, the Union may
override it::
The :meth:`!__or__` method for type objects was added to support the syntax
``X | Y``. If a metaclass implements :meth:`!__or__`, the Union may
override it:

.. doctest::

>>> class M(type):
... def __or__(self, other):
Expand All@@ -5192,7 +5196,7 @@ instantiated from the type::
>>> C | int
'Hello'
>>> int | C
int |__main__.C
int | C

.. seealso::

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp