mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
GH-97950: Use new-style index directive ('object') (#104158)
* Uncomment object removal in pairindextypes
* Use new-style index directive ('object') - C API
* Use new-style index directive ('object') - Library
* Use new-style index directive ('object') - Reference
* Use new-style index directive ('object') - Tutorial
This commit is contained in:
parent
b0ce2db118
commit
6ab463684b
31 changed files with 143 additions and 143 deletions
|
|
@ -147,7 +147,7 @@ The :keyword:`!for` statement
|
|||
pair: keyword; else
|
||||
pair: target; list
|
||||
pair: loop; statement
|
||||
object: sequence
|
||||
pair: object; sequence
|
||||
single: : (colon); compound statement
|
||||
|
||||
The :keyword:`for` statement is used to iterate over the elements of a sequence
|
||||
|
|
@ -298,7 +298,7 @@ keeping all locals in that frame alive until the next garbage collection occurs.
|
|||
|
||||
.. index::
|
||||
pair: module; sys
|
||||
object: traceback
|
||||
pair: object; traceback
|
||||
|
||||
Before an :keyword:`!except` clause's suite is executed,
|
||||
the exception is stored in the :mod:`sys` module, where it can be accessed
|
||||
|
|
@ -1194,8 +1194,8 @@ Function definitions
|
|||
pair: function; definition
|
||||
pair: function; name
|
||||
pair: name; binding
|
||||
object: user-defined function
|
||||
object: function
|
||||
pair: object; user-defined function
|
||||
pair: object; function
|
||||
pair: function; name
|
||||
pair: name; binding
|
||||
single: () (parentheses); function definition
|
||||
|
|
@ -1363,7 +1363,7 @@ Class definitions
|
|||
=================
|
||||
|
||||
.. index::
|
||||
object: class
|
||||
pair: object; class
|
||||
statement: class
|
||||
pair: class; definition
|
||||
pair: class; name
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ attributes.' These are attributes that provide access to the implementation and
|
|||
are not intended for general use. Their definition may change in the future.
|
||||
|
||||
None
|
||||
.. index:: object: None
|
||||
.. index:: pair: object; None
|
||||
|
||||
This type has a single value. There is a single object with this value. This
|
||||
object is accessed through the built-in name ``None``. It is used to signify the
|
||||
|
|
@ -150,7 +150,7 @@ None
|
|||
don't explicitly return anything. Its truth value is false.
|
||||
|
||||
NotImplemented
|
||||
.. index:: object: NotImplemented
|
||||
.. index:: pair: object; NotImplemented
|
||||
|
||||
This type has a single value. There is a single object with this value. This
|
||||
object is accessed through the built-in name ``NotImplemented``. Numeric methods
|
||||
|
|
@ -171,7 +171,7 @@ NotImplemented
|
|||
|
||||
Ellipsis
|
||||
.. index::
|
||||
object: Ellipsis
|
||||
pair: object; Ellipsis
|
||||
single: ...; ellipsis literal
|
||||
|
||||
This type has a single value. There is a single object with this value. This
|
||||
|
|
@ -179,7 +179,7 @@ Ellipsis
|
|||
``Ellipsis``. Its truth value is true.
|
||||
|
||||
:class:`numbers.Number`
|
||||
.. index:: object: numeric
|
||||
.. index:: pair: object; numeric
|
||||
|
||||
These are created by numeric literals and returned as results by arithmetic
|
||||
operators and arithmetic built-in functions. Numeric objects are immutable;
|
||||
|
|
@ -209,7 +209,7 @@ Ellipsis
|
|||
numbers:
|
||||
|
||||
:class:`numbers.Integral`
|
||||
.. index:: object: integer
|
||||
.. index:: pair: object; integer
|
||||
|
||||
These represent elements from the mathematical set of integers (positive and
|
||||
negative).
|
||||
|
|
@ -225,7 +225,7 @@ Ellipsis
|
|||
|
||||
Booleans (:class:`bool`)
|
||||
.. index::
|
||||
object: Boolean
|
||||
pair: object; Boolean
|
||||
single: False
|
||||
single: True
|
||||
|
||||
|
|
@ -242,7 +242,7 @@ Ellipsis
|
|||
|
||||
:class:`numbers.Real` (:class:`float`)
|
||||
.. index::
|
||||
object: floating point
|
||||
pair: object; floating point
|
||||
pair: floating point; number
|
||||
pair: C; language
|
||||
pair: Java; language
|
||||
|
|
@ -257,7 +257,7 @@ Ellipsis
|
|||
|
||||
:class:`numbers.Complex` (:class:`complex`)
|
||||
.. index::
|
||||
object: complex
|
||||
pair: object; complex
|
||||
pair: complex; number
|
||||
|
||||
These represent complex numbers as a pair of machine-level double precision
|
||||
|
|
@ -268,7 +268,7 @@ Ellipsis
|
|||
Sequences
|
||||
.. index::
|
||||
builtin: len
|
||||
object: sequence
|
||||
pair: object; sequence
|
||||
single: index operation
|
||||
single: item selection
|
||||
single: subscription
|
||||
|
|
@ -293,8 +293,8 @@ Sequences
|
|||
|
||||
Immutable sequences
|
||||
.. index::
|
||||
object: immutable sequence
|
||||
object: immutable
|
||||
pair: object; immutable sequence
|
||||
pair: object; immutable
|
||||
|
||||
An object of an immutable sequence type cannot change once it is created. (If
|
||||
the object contains references to other objects, these other objects may be
|
||||
|
|
@ -328,7 +328,7 @@ Sequences
|
|||
|
||||
Tuples
|
||||
.. index::
|
||||
object: tuple
|
||||
pair: object; tuple
|
||||
pair: singleton; tuple
|
||||
pair: empty; tuple
|
||||
|
||||
|
|
@ -350,8 +350,8 @@ Sequences
|
|||
|
||||
Mutable sequences
|
||||
.. index::
|
||||
object: mutable sequence
|
||||
object: mutable
|
||||
pair: object; mutable sequence
|
||||
pair: object; mutable
|
||||
pair: assignment; statement
|
||||
single: subscription
|
||||
single: slicing
|
||||
|
|
@ -363,7 +363,7 @@ Sequences
|
|||
There are currently two intrinsic mutable sequence types:
|
||||
|
||||
Lists
|
||||
.. index:: object: list
|
||||
.. index:: pair: object; list
|
||||
|
||||
The items of a list are arbitrary Python objects. Lists are formed by
|
||||
placing a comma-separated list of expressions in square brackets. (Note
|
||||
|
|
@ -385,7 +385,7 @@ Sequences
|
|||
Set types
|
||||
.. index::
|
||||
builtin: len
|
||||
object: set type
|
||||
pair: object; set type
|
||||
|
||||
These represent unordered, finite sets of unique, immutable objects. As such,
|
||||
they cannot be indexed by any subscript. However, they can be iterated over, and
|
||||
|
|
@ -402,14 +402,14 @@ Set types
|
|||
There are currently two intrinsic set types:
|
||||
|
||||
Sets
|
||||
.. index:: object: set
|
||||
.. index:: pair: object; set
|
||||
|
||||
These represent a mutable set. They are created by the built-in :func:`set`
|
||||
constructor and can be modified afterwards by several methods, such as
|
||||
:meth:`~set.add`.
|
||||
|
||||
Frozen sets
|
||||
.. index:: object: frozenset
|
||||
.. index:: pair: object; frozenset
|
||||
|
||||
These represent an immutable set. They are created by the built-in
|
||||
:func:`frozenset` constructor. As a frozenset is immutable and
|
||||
|
|
@ -420,7 +420,7 @@ Mappings
|
|||
.. index::
|
||||
builtin: len
|
||||
single: subscription
|
||||
object: mapping
|
||||
pair: object; mapping
|
||||
|
||||
These represent finite sets of objects indexed by arbitrary index sets. The
|
||||
subscript notation ``a[k]`` selects the item indexed by ``k`` from the mapping
|
||||
|
|
@ -431,7 +431,7 @@ Mappings
|
|||
There is currently a single intrinsic mapping type:
|
||||
|
||||
Dictionaries
|
||||
.. index:: object: dictionary
|
||||
.. index:: pair: object; dictionary
|
||||
|
||||
These represent finite sets of objects indexed by nearly arbitrary values. The
|
||||
only types of values not acceptable as keys are values containing lists or
|
||||
|
|
@ -465,7 +465,7 @@ Mappings
|
|||
|
||||
Callable types
|
||||
.. index::
|
||||
object: callable
|
||||
pair: object; callable
|
||||
pair: function; call
|
||||
single: invocation
|
||||
pair: function; argument
|
||||
|
|
@ -476,8 +476,8 @@ Callable types
|
|||
User-defined functions
|
||||
.. index::
|
||||
pair: user-defined; function
|
||||
object: function
|
||||
object: user-defined function
|
||||
pair: object; function
|
||||
pair: object; user-defined function
|
||||
|
||||
A user-defined function object is created by a function definition (see
|
||||
section :ref:`function`). It should be called with an argument list
|
||||
|
|
@ -580,8 +580,8 @@ Callable types
|
|||
|
||||
Instance methods
|
||||
.. index::
|
||||
object: method
|
||||
object: user-defined method
|
||||
pair: object; method
|
||||
pair: object; user-defined method
|
||||
pair: user-defined; method
|
||||
|
||||
An instance method object combines a class, a class instance and any
|
||||
|
|
@ -688,8 +688,8 @@ Callable types
|
|||
|
||||
Built-in functions
|
||||
.. index::
|
||||
object: built-in function
|
||||
object: function
|
||||
pair: object; built-in function
|
||||
pair: object; function
|
||||
pair: C; language
|
||||
|
||||
A built-in function object is a wrapper around a C function. Examples of
|
||||
|
|
@ -703,8 +703,8 @@ Callable types
|
|||
|
||||
Built-in methods
|
||||
.. index::
|
||||
object: built-in method
|
||||
object: method
|
||||
pair: object; built-in method
|
||||
pair: object; method
|
||||
pair: built-in; method
|
||||
|
||||
This is really a different disguise of a built-in function, this time containing
|
||||
|
|
@ -728,7 +728,7 @@ Callable types
|
|||
Modules
|
||||
.. index::
|
||||
statement: import
|
||||
object: module
|
||||
pair: object; module
|
||||
|
||||
Modules are a basic organizational unit of Python code, and are created by
|
||||
the :ref:`import system <importsystem>` as invoked either by the
|
||||
|
|
@ -805,12 +805,12 @@ Custom classes
|
|||
.. XXX: Could we add that MRO doc as an appendix to the language ref?
|
||||
|
||||
.. index::
|
||||
object: class
|
||||
object: class instance
|
||||
object: instance
|
||||
pair: object; class
|
||||
pair: object; class instance
|
||||
pair: object; instance
|
||||
pair: class object; call
|
||||
single: container
|
||||
object: dictionary
|
||||
pair: object; dictionary
|
||||
pair: class; attribute
|
||||
|
||||
When a class attribute reference (for class :class:`C`, say) would yield a
|
||||
|
|
@ -865,8 +865,8 @@ Custom classes
|
|||
|
||||
Class instances
|
||||
.. index::
|
||||
object: class instance
|
||||
object: instance
|
||||
pair: object; class instance
|
||||
pair: object; instance
|
||||
pair: class; instance
|
||||
pair: class instance; attribute
|
||||
|
||||
|
|
@ -892,9 +892,9 @@ Class instances
|
|||
dictionary directly.
|
||||
|
||||
.. index::
|
||||
object: numeric
|
||||
object: sequence
|
||||
object: mapping
|
||||
pair: object; numeric
|
||||
pair: object; sequence
|
||||
pair: object; mapping
|
||||
|
||||
Class instances can pretend to be numbers, sequences, or mappings if they have
|
||||
methods with certain special names. See section :ref:`specialnames`.
|
||||
|
|
@ -996,7 +996,7 @@ Internal types
|
|||
required stack size; :attr:`co_flags` is an integer encoding a number
|
||||
of flags for the interpreter.
|
||||
|
||||
.. index:: object: generator
|
||||
.. index:: pair: object; generator
|
||||
|
||||
The following flag bits are defined for :attr:`co_flags`: bit ``0x04`` is set if
|
||||
the function uses the ``*arguments`` syntax to accept an arbitrary number of
|
||||
|
|
@ -1053,7 +1053,7 @@ Internal types
|
|||
.. _frame-objects:
|
||||
|
||||
Frame objects
|
||||
.. index:: object: frame
|
||||
.. index:: pair: object; frame
|
||||
|
||||
Frame objects represent execution frames. They may occur in traceback objects
|
||||
(see below), and are also passed to registered trace functions.
|
||||
|
|
@ -1116,7 +1116,7 @@ Internal types
|
|||
|
||||
Traceback objects
|
||||
.. index::
|
||||
object: traceback
|
||||
pair: object; traceback
|
||||
pair: stack; trace
|
||||
pair: exception; handler
|
||||
pair: execution; stack
|
||||
|
|
@ -1498,7 +1498,7 @@ Basic customization
|
|||
.. method:: object.__hash__(self)
|
||||
|
||||
.. index::
|
||||
object: dictionary
|
||||
pair: object; dictionary
|
||||
builtin: hash
|
||||
|
||||
Called by built-in function :func:`hash` and for operations on members of
|
||||
|
|
@ -2506,7 +2506,7 @@ through the object's keys; for sequences, it should iterate through the values.
|
|||
.. versionadded:: 3.4
|
||||
|
||||
|
||||
.. index:: object: slice
|
||||
.. index:: pair: object; slice
|
||||
|
||||
.. note::
|
||||
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ List displays
|
|||
pair: list; display
|
||||
pair: list; comprehensions
|
||||
pair: empty; list
|
||||
object: list
|
||||
pair: object; list
|
||||
single: [] (square brackets); list expression
|
||||
single: , (comma); expression list
|
||||
|
||||
|
|
@ -270,7 +270,7 @@ Set displays
|
|||
.. index::
|
||||
pair: set; display
|
||||
pair: set; comprehensions
|
||||
object: set
|
||||
pair: object; set
|
||||
single: {} (curly brackets); set expression
|
||||
single: , (comma); expression list
|
||||
|
||||
|
|
@ -299,7 +299,7 @@ Dictionary displays
|
|||
pair: dictionary; display
|
||||
pair: dictionary; comprehensions
|
||||
key, datum, key/datum pair
|
||||
object: dictionary
|
||||
pair: object; dictionary
|
||||
single: {} (curly brackets); dictionary expression
|
||||
single: : (colon); in dictionary expressions
|
||||
single: , (comma); in dictionary displays
|
||||
|
|
@ -361,7 +361,7 @@ Generator expressions
|
|||
|
||||
.. index::
|
||||
pair: generator; expression
|
||||
object: generator
|
||||
pair: object; generator
|
||||
single: () (parentheses); generator expression
|
||||
|
||||
A generator expression is a compact generator notation in parentheses:
|
||||
|
|
@ -522,7 +522,7 @@ on the right hand side of an assignment statement.
|
|||
The proposal that expanded on :pep:`492` by adding generator capabilities to
|
||||
coroutine functions.
|
||||
|
||||
.. index:: object: generator
|
||||
.. index:: pair: object; generator
|
||||
.. _generator-methods:
|
||||
|
||||
Generator-iterator methods
|
||||
|
|
@ -701,7 +701,7 @@ of a *finalizer* method see the implementation of
|
|||
The expression ``yield from <expr>`` is a syntax error when used in an
|
||||
asynchronous generator function.
|
||||
|
||||
.. index:: object: asynchronous-generator
|
||||
.. index:: pair: object; asynchronous-generator
|
||||
.. _asynchronous-generator-methods:
|
||||
|
||||
Asynchronous generator-iterator methods
|
||||
|
|
@ -811,8 +811,8 @@ An attribute reference is a primary followed by a period and a name:
|
|||
|
||||
.. index::
|
||||
exception: AttributeError
|
||||
object: module
|
||||
object: list
|
||||
pair: object; module
|
||||
pair: object; list
|
||||
|
||||
The primary must evaluate to an object of a type that supports attribute
|
||||
references, which most objects do. This object is then asked to produce the
|
||||
|
|
@ -833,12 +833,12 @@ Subscriptions
|
|||
single: [] (square brackets); subscription
|
||||
|
||||
.. index::
|
||||
object: sequence
|
||||
object: mapping
|
||||
object: string
|
||||
object: tuple
|
||||
object: list
|
||||
object: dictionary
|
||||
pair: object; sequence
|
||||
pair: object; mapping
|
||||
pair: object; string
|
||||
pair: object; tuple
|
||||
pair: object; list
|
||||
pair: object; dictionary
|
||||
pair: sequence; item
|
||||
|
||||
The subscription of an instance of a :ref:`container class <sequence-types>`
|
||||
|
|
@ -906,10 +906,10 @@ Slicings
|
|||
single: , (comma); slicing
|
||||
|
||||
.. index::
|
||||
object: sequence
|
||||
object: string
|
||||
object: tuple
|
||||
object: list
|
||||
pair: object; sequence
|
||||
pair: object; string
|
||||
pair: object; tuple
|
||||
pair: object; list
|
||||
|
||||
A slicing selects a range of items in a sequence object (e.g., a string, tuple
|
||||
or list). Slicings may be used as expressions or as targets in assignment or
|
||||
|
|
@ -950,7 +950,7 @@ substituting ``None`` for missing expressions.
|
|||
|
||||
|
||||
.. index::
|
||||
object: callable
|
||||
pair: object; callable
|
||||
single: call
|
||||
single: argument; call semantics
|
||||
single: () (parentheses); call
|
||||
|
|
@ -1100,8 +1100,8 @@ a user-defined function:
|
|||
.. index::
|
||||
pair: function; call
|
||||
triple: user-defined; function; call
|
||||
object: user-defined function
|
||||
object: function
|
||||
pair: object; user-defined function
|
||||
pair: object; function
|
||||
|
||||
The code block for the function is executed, passing it the argument list. The
|
||||
first thing the code block will do is bind the formal parameters to the
|
||||
|
|
@ -1115,25 +1115,25 @@ a built-in function or method:
|
|||
pair: built-in function; call
|
||||
pair: method; call
|
||||
pair: built-in method; call
|
||||
object: built-in method
|
||||
object: built-in function
|
||||
object: method
|
||||
object: function
|
||||
pair: object; built-in method
|
||||
pair: object; built-in function
|
||||
pair: object; method
|
||||
pair: object; function
|
||||
|
||||
The result is up to the interpreter; see :ref:`built-in-funcs` for the
|
||||
descriptions of built-in functions and methods.
|
||||
|
||||
a class object:
|
||||
.. index::
|
||||
object: class
|
||||
pair: object; class
|
||||
pair: class object; call
|
||||
|
||||
A new instance of that class is returned.
|
||||
|
||||
a class instance method:
|
||||
.. index::
|
||||
object: class instance
|
||||
object: instance
|
||||
pair: object; class instance
|
||||
pair: object; instance
|
||||
pair: class instance; call
|
||||
|
||||
The corresponding user-defined function is called, with an argument list that is
|
||||
|
|
@ -1672,7 +1672,7 @@ if :keyword:`in` raised that exception).
|
|||
pair: operator; in
|
||||
pair: operator; not in
|
||||
pair: membership; test
|
||||
object: sequence
|
||||
pair: object; sequence
|
||||
|
||||
The operator :keyword:`not in` is defined to have the inverse truth value of
|
||||
:keyword:`in`.
|
||||
|
|
@ -1854,7 +1854,7 @@ Expression lists
|
|||
starred_expression: `expression` | (`starred_item` ",")* [`starred_item`]
|
||||
starred_item: `assignment_expression` | "*" `or_expr`
|
||||
|
||||
.. index:: object: tuple
|
||||
.. index:: pair: object; tuple
|
||||
|
||||
Except when part of a list or set display, an expression list
|
||||
containing at least one comma yields a tuple. The length of
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ expression).
|
|||
|
||||
.. index::
|
||||
builtin: repr
|
||||
object: None
|
||||
pair: object; None
|
||||
pair: string; conversion
|
||||
single: output
|
||||
pair: standard; output
|
||||
|
|
@ -76,7 +76,7 @@ Assignment statements
|
|||
pair: assignment; statement
|
||||
pair: binding; name
|
||||
pair: rebinding; name
|
||||
object: mutable
|
||||
pair: object; mutable
|
||||
pair: attribute; assignment
|
||||
|
||||
Assignment statements are used to (re)bind names to values and to modify
|
||||
|
|
@ -185,7 +185,7 @@ Assignment of an object to a single target is recursively defined as follows.
|
|||
|
||||
.. index::
|
||||
pair: subscription; assignment
|
||||
object: mutable
|
||||
pair: object; mutable
|
||||
|
||||
* If the target is a subscription: The primary expression in the reference is
|
||||
evaluated. It should yield either a mutable sequence object (such as a list)
|
||||
|
|
@ -193,8 +193,8 @@ Assignment of an object to a single target is recursively defined as follows.
|
|||
evaluated.
|
||||
|
||||
.. index::
|
||||
object: sequence
|
||||
object: list
|
||||
pair: object; sequence
|
||||
pair: object; list
|
||||
|
||||
If the primary is a mutable sequence object (such as a list), the subscript
|
||||
must yield an integer. If it is negative, the sequence's length is added to
|
||||
|
|
@ -204,8 +204,8 @@ Assignment of an object to a single target is recursively defined as follows.
|
|||
raised (assignment to a subscripted sequence cannot add new items to a list).
|
||||
|
||||
.. index::
|
||||
object: mapping
|
||||
object: dictionary
|
||||
pair: object; mapping
|
||||
pair: object; dictionary
|
||||
|
||||
If the primary is a mapping object (such as a dictionary), the subscript must
|
||||
have a type compatible with the mapping's key type, and the mapping is then
|
||||
|
|
@ -574,7 +574,7 @@ instantiating the class with no arguments.
|
|||
The :dfn:`type` of the exception is the exception instance's class, the
|
||||
:dfn:`value` is the instance itself.
|
||||
|
||||
.. index:: object: traceback
|
||||
.. index:: pair: object; traceback
|
||||
|
||||
A traceback object is normally created automatically when an exception is raised
|
||||
and attached to it as the :attr:`__traceback__` attribute, which is writable.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue