mirror of https://github.com/python/cpython
GH-97950: Use new-style index directive ('builtin') (#104164)
* Uncomment builtin removal in pairindextypes * Use new-style index directive ('builtin') - C API * Use new-style index directive ('builtin') - Extending * Use new-style index directive ('builtin') - Library * Use new-style index directive ('builtin') - Reference * Use new-style index directive ('builtin') - Tutorial
This commit is contained in:
parent
4cd95dce0b
commit
f5088006ca
|
@ -154,7 +154,7 @@ Dictionary Objects
|
||||||
|
|
||||||
.. c:function:: Py_ssize_t PyDict_Size(PyObject *p)
|
.. c:function:: Py_ssize_t PyDict_Size(PyObject *p)
|
||||||
|
|
||||||
.. index:: builtin: len
|
.. index:: pair: built-in function; len
|
||||||
|
|
||||||
Return the number of items in the dictionary. This is equivalent to
|
Return the number of items in the dictionary. This is equivalent to
|
||||||
``len(p)`` on a dictionary.
|
``len(p)`` on a dictionary.
|
||||||
|
|
|
@ -41,7 +41,7 @@ Importing Modules
|
||||||
|
|
||||||
.. c:function:: PyObject* PyImport_ImportModuleEx(const char *name, PyObject *globals, PyObject *locals, PyObject *fromlist)
|
.. c:function:: PyObject* PyImport_ImportModuleEx(const char *name, PyObject *globals, PyObject *locals, PyObject *fromlist)
|
||||||
|
|
||||||
.. index:: builtin: __import__
|
.. index:: pair: built-in function; __import__
|
||||||
|
|
||||||
Import a module. This is best described by referring to the built-in Python
|
Import a module. This is best described by referring to the built-in Python
|
||||||
function :func:`__import__`.
|
function :func:`__import__`.
|
||||||
|
@ -120,7 +120,7 @@ Importing Modules
|
||||||
|
|
||||||
.. c:function:: PyObject* PyImport_ExecCodeModule(const char *name, PyObject *co)
|
.. c:function:: PyObject* PyImport_ExecCodeModule(const char *name, PyObject *co)
|
||||||
|
|
||||||
.. index:: builtin: compile
|
.. index:: pair: built-in function; compile
|
||||||
|
|
||||||
Given a module name (possibly of the form ``package.module``) and a code object
|
Given a module name (possibly of the form ``package.module``) and a code object
|
||||||
read from a Python bytecode file or obtained from the built-in function
|
read from a Python bytecode file or obtained from the built-in function
|
||||||
|
|
|
@ -45,7 +45,7 @@ List Objects
|
||||||
|
|
||||||
.. c:function:: Py_ssize_t PyList_Size(PyObject *list)
|
.. c:function:: Py_ssize_t PyList_Size(PyObject *list)
|
||||||
|
|
||||||
.. index:: builtin: len
|
.. index:: pair: built-in function; len
|
||||||
|
|
||||||
Return the length of the list object in *list*; this is equivalent to
|
Return the length of the list object in *list*; this is equivalent to
|
||||||
``len(list)`` on a list object.
|
``len(list)`` on a list object.
|
||||||
|
@ -138,7 +138,7 @@ List Objects
|
||||||
|
|
||||||
.. c:function:: PyObject* PyList_AsTuple(PyObject *list)
|
.. c:function:: PyObject* PyList_AsTuple(PyObject *list)
|
||||||
|
|
||||||
.. index:: builtin: tuple
|
.. index:: pair: built-in function; tuple
|
||||||
|
|
||||||
Return a new tuple object containing the contents of *list*; equivalent to
|
Return a new tuple object containing the contents of *list*; equivalent to
|
||||||
``tuple(list)``.
|
``tuple(list)``.
|
||||||
|
|
|
@ -20,7 +20,7 @@ See also :c:func:`PyObject_GetItem`, :c:func:`PyObject_SetItem` and
|
||||||
.. c:function:: Py_ssize_t PyMapping_Size(PyObject *o)
|
.. c:function:: Py_ssize_t PyMapping_Size(PyObject *o)
|
||||||
Py_ssize_t PyMapping_Length(PyObject *o)
|
Py_ssize_t PyMapping_Length(PyObject *o)
|
||||||
|
|
||||||
.. index:: builtin: len
|
.. index:: pair: built-in function; len
|
||||||
|
|
||||||
Returns the number of keys in object *o* on success, and ``-1`` on failure.
|
Returns the number of keys in object *o* on success, and ``-1`` on failure.
|
||||||
This is equivalent to the Python expression ``len(o)``.
|
This is equivalent to the Python expression ``len(o)``.
|
||||||
|
|
|
@ -64,7 +64,7 @@ Number Protocol
|
||||||
|
|
||||||
.. c:function:: PyObject* PyNumber_Divmod(PyObject *o1, PyObject *o2)
|
.. c:function:: PyObject* PyNumber_Divmod(PyObject *o1, PyObject *o2)
|
||||||
|
|
||||||
.. index:: builtin: divmod
|
.. index:: pair: built-in function; divmod
|
||||||
|
|
||||||
See the built-in function :func:`divmod`. Returns ``NULL`` on failure. This is
|
See the built-in function :func:`divmod`. Returns ``NULL`` on failure. This is
|
||||||
the equivalent of the Python expression ``divmod(o1, o2)``.
|
the equivalent of the Python expression ``divmod(o1, o2)``.
|
||||||
|
@ -72,7 +72,7 @@ Number Protocol
|
||||||
|
|
||||||
.. c:function:: PyObject* PyNumber_Power(PyObject *o1, PyObject *o2, PyObject *o3)
|
.. c:function:: PyObject* PyNumber_Power(PyObject *o1, PyObject *o2, PyObject *o3)
|
||||||
|
|
||||||
.. index:: builtin: pow
|
.. index:: pair: built-in function; pow
|
||||||
|
|
||||||
See the built-in function :func:`pow`. Returns ``NULL`` on failure. This is the
|
See the built-in function :func:`pow`. Returns ``NULL`` on failure. This is the
|
||||||
equivalent of the Python expression ``pow(o1, o2, o3)``, where *o3* is optional.
|
equivalent of the Python expression ``pow(o1, o2, o3)``, where *o3* is optional.
|
||||||
|
@ -94,7 +94,7 @@ Number Protocol
|
||||||
|
|
||||||
.. c:function:: PyObject* PyNumber_Absolute(PyObject *o)
|
.. c:function:: PyObject* PyNumber_Absolute(PyObject *o)
|
||||||
|
|
||||||
.. index:: builtin: abs
|
.. index:: pair: built-in function; abs
|
||||||
|
|
||||||
Returns the absolute value of *o*, or ``NULL`` on failure. This is the equivalent
|
Returns the absolute value of *o*, or ``NULL`` on failure. This is the equivalent
|
||||||
of the Python expression ``abs(o)``.
|
of the Python expression ``abs(o)``.
|
||||||
|
@ -192,7 +192,7 @@ Number Protocol
|
||||||
|
|
||||||
.. c:function:: PyObject* PyNumber_InPlacePower(PyObject *o1, PyObject *o2, PyObject *o3)
|
.. c:function:: PyObject* PyNumber_InPlacePower(PyObject *o1, PyObject *o2, PyObject *o3)
|
||||||
|
|
||||||
.. index:: builtin: pow
|
.. index:: pair: built-in function; pow
|
||||||
|
|
||||||
See the built-in function :func:`pow`. Returns ``NULL`` on failure. The operation
|
See the built-in function :func:`pow`. Returns ``NULL`` on failure. The operation
|
||||||
is done *in-place* when *o1* supports it. This is the equivalent of the Python
|
is done *in-place* when *o1* supports it. This is the equivalent of the Python
|
||||||
|
@ -238,7 +238,7 @@ Number Protocol
|
||||||
|
|
||||||
.. c:function:: PyObject* PyNumber_Long(PyObject *o)
|
.. c:function:: PyObject* PyNumber_Long(PyObject *o)
|
||||||
|
|
||||||
.. index:: builtin: int
|
.. index:: pair: built-in function; int
|
||||||
|
|
||||||
Returns the *o* converted to an integer object on success, or ``NULL`` on
|
Returns the *o* converted to an integer object on success, or ``NULL`` on
|
||||||
failure. This is the equivalent of the Python expression ``int(o)``.
|
failure. This is the equivalent of the Python expression ``int(o)``.
|
||||||
|
@ -246,7 +246,7 @@ Number Protocol
|
||||||
|
|
||||||
.. c:function:: PyObject* PyNumber_Float(PyObject *o)
|
.. c:function:: PyObject* PyNumber_Float(PyObject *o)
|
||||||
|
|
||||||
.. index:: builtin: float
|
.. index:: pair: built-in function; float
|
||||||
|
|
||||||
Returns the *o* converted to a float object on success, or ``NULL`` on failure.
|
Returns the *o* converted to a float object on success, or ``NULL`` on failure.
|
||||||
This is the equivalent of the Python expression ``float(o)``.
|
This is the equivalent of the Python expression ``float(o)``.
|
||||||
|
|
|
@ -190,7 +190,7 @@ Object Protocol
|
||||||
|
|
||||||
.. c:function:: PyObject* PyObject_Repr(PyObject *o)
|
.. c:function:: PyObject* PyObject_Repr(PyObject *o)
|
||||||
|
|
||||||
.. index:: builtin: repr
|
.. index:: pair: built-in function; repr
|
||||||
|
|
||||||
Compute a string representation of object *o*. Returns the string
|
Compute a string representation of object *o*. Returns the string
|
||||||
representation on success, ``NULL`` on failure. This is the equivalent of the
|
representation on success, ``NULL`` on failure. This is the equivalent of the
|
||||||
|
@ -202,7 +202,7 @@ Object Protocol
|
||||||
|
|
||||||
.. c:function:: PyObject* PyObject_ASCII(PyObject *o)
|
.. c:function:: PyObject* PyObject_ASCII(PyObject *o)
|
||||||
|
|
||||||
.. index:: builtin: ascii
|
.. index:: pair: built-in function; ascii
|
||||||
|
|
||||||
As :c:func:`PyObject_Repr`, compute a string representation of object *o*, but
|
As :c:func:`PyObject_Repr`, compute a string representation of object *o*, but
|
||||||
escape the non-ASCII characters in the string returned by
|
escape the non-ASCII characters in the string returned by
|
||||||
|
@ -227,7 +227,7 @@ Object Protocol
|
||||||
|
|
||||||
.. c:function:: PyObject* PyObject_Bytes(PyObject *o)
|
.. c:function:: PyObject* PyObject_Bytes(PyObject *o)
|
||||||
|
|
||||||
.. index:: builtin: bytes
|
.. index:: pair: built-in function; bytes
|
||||||
|
|
||||||
Compute a bytes representation of object *o*. ``NULL`` is returned on
|
Compute a bytes representation of object *o*. ``NULL`` is returned on
|
||||||
failure and a bytes object on success. This is equivalent to the Python
|
failure and a bytes object on success. This is equivalent to the Python
|
||||||
|
@ -278,7 +278,7 @@ Object Protocol
|
||||||
|
|
||||||
.. c:function:: Py_hash_t PyObject_Hash(PyObject *o)
|
.. c:function:: Py_hash_t PyObject_Hash(PyObject *o)
|
||||||
|
|
||||||
.. index:: builtin: hash
|
.. index:: pair: built-in function; hash
|
||||||
|
|
||||||
Compute and return the hash value of an object *o*. On failure, return ``-1``.
|
Compute and return the hash value of an object *o*. On failure, return ``-1``.
|
||||||
This is the equivalent of the Python expression ``hash(o)``.
|
This is the equivalent of the Python expression ``hash(o)``.
|
||||||
|
@ -312,7 +312,7 @@ Object Protocol
|
||||||
|
|
||||||
.. c:function:: PyObject* PyObject_Type(PyObject *o)
|
.. c:function:: PyObject* PyObject_Type(PyObject *o)
|
||||||
|
|
||||||
.. index:: builtin: type
|
.. index:: pair: built-in function; type
|
||||||
|
|
||||||
When *o* is non-``NULL``, returns a type object corresponding to the object type
|
When *o* is non-``NULL``, returns a type object corresponding to the object type
|
||||||
of object *o*. On failure, raises :exc:`SystemError` and returns ``NULL``. This
|
of object *o*. On failure, raises :exc:`SystemError` and returns ``NULL``. This
|
||||||
|
@ -332,7 +332,7 @@ Object Protocol
|
||||||
.. c:function:: Py_ssize_t PyObject_Size(PyObject *o)
|
.. c:function:: Py_ssize_t PyObject_Size(PyObject *o)
|
||||||
Py_ssize_t PyObject_Length(PyObject *o)
|
Py_ssize_t PyObject_Length(PyObject *o)
|
||||||
|
|
||||||
.. index:: builtin: len
|
.. index:: pair: built-in function; len
|
||||||
|
|
||||||
Return the length of object *o*. If the object *o* provides either the sequence
|
Return the length of object *o*. If the object *o* provides either the sequence
|
||||||
and mapping protocols, the sequence length is returned. On error, ``-1`` is
|
and mapping protocols, the sequence length is returned. On error, ``-1`` is
|
||||||
|
|
|
@ -18,7 +18,7 @@ Sequence Protocol
|
||||||
.. c:function:: Py_ssize_t PySequence_Size(PyObject *o)
|
.. c:function:: Py_ssize_t PySequence_Size(PyObject *o)
|
||||||
Py_ssize_t PySequence_Length(PyObject *o)
|
Py_ssize_t PySequence_Length(PyObject *o)
|
||||||
|
|
||||||
.. index:: builtin: len
|
.. index:: pair: built-in function; len
|
||||||
|
|
||||||
Returns the number of objects in sequence *o* on success, and ``-1`` on
|
Returns the number of objects in sequence *o* on success, and ``-1`` on
|
||||||
failure. This is equivalent to the Python expression ``len(o)``.
|
failure. This is equivalent to the Python expression ``len(o)``.
|
||||||
|
@ -120,7 +120,7 @@ Sequence Protocol
|
||||||
|
|
||||||
.. c:function:: PyObject* PySequence_Tuple(PyObject *o)
|
.. c:function:: PyObject* PySequence_Tuple(PyObject *o)
|
||||||
|
|
||||||
.. index:: builtin: tuple
|
.. index:: pair: built-in function; tuple
|
||||||
|
|
||||||
Return a tuple object with the same contents as the sequence or iterable *o*,
|
Return a tuple object with the same contents as the sequence or iterable *o*,
|
||||||
or ``NULL`` on failure. If *o* is a tuple, a new reference will be returned,
|
or ``NULL`` on failure. If *o* is a tuple, a new reference will be returned,
|
||||||
|
|
|
@ -107,7 +107,7 @@ or :class:`frozenset` or instances of their subtypes.
|
||||||
|
|
||||||
.. c:function:: Py_ssize_t PySet_Size(PyObject *anyset)
|
.. c:function:: Py_ssize_t PySet_Size(PyObject *anyset)
|
||||||
|
|
||||||
.. index:: builtin: len
|
.. index:: pair: built-in function; len
|
||||||
|
|
||||||
Return the length of a :class:`set` or :class:`frozenset` object. Equivalent to
|
Return the length of a :class:`set` or :class:`frozenset` object. Equivalent to
|
||||||
``len(anyset)``. Raises a :exc:`PyExc_SystemError` if *anyset* is not a
|
``len(anyset)``. Raises a :exc:`PyExc_SystemError` if *anyset* is not a
|
||||||
|
|
|
@ -347,7 +347,7 @@ method.
|
||||||
|
|
||||||
.. data:: METH_CLASS
|
.. data:: METH_CLASS
|
||||||
|
|
||||||
.. index:: builtin: classmethod
|
.. index:: pair: built-in function; classmethod
|
||||||
|
|
||||||
The method will be passed the type object as the first parameter rather
|
The method will be passed the type object as the first parameter rather
|
||||||
than an instance of the type. This is used to create *class methods*,
|
than an instance of the type. This is used to create *class methods*,
|
||||||
|
@ -357,7 +357,7 @@ method.
|
||||||
|
|
||||||
.. data:: METH_STATIC
|
.. data:: METH_STATIC
|
||||||
|
|
||||||
.. index:: builtin: staticmethod
|
.. index:: pair: built-in function; staticmethod
|
||||||
|
|
||||||
The method will be passed ``NULL`` as the first parameter rather than an
|
The method will be passed ``NULL`` as the first parameter rather than an
|
||||||
instance of the type. This is used to create *static methods*, similar to
|
instance of the type. This is used to create *static methods*, similar to
|
||||||
|
|
|
@ -805,7 +805,7 @@ and :c:type:`PyType_Type` effectively act as defaults.)
|
||||||
|
|
||||||
.. c:member:: reprfunc PyTypeObject.tp_repr
|
.. c:member:: reprfunc PyTypeObject.tp_repr
|
||||||
|
|
||||||
.. index:: builtin: repr
|
.. index:: pair: built-in function; repr
|
||||||
|
|
||||||
An optional pointer to a function that implements the built-in function
|
An optional pointer to a function that implements the built-in function
|
||||||
:func:`repr`.
|
:func:`repr`.
|
||||||
|
@ -870,7 +870,7 @@ and :c:type:`PyType_Type` effectively act as defaults.)
|
||||||
|
|
||||||
.. c:member:: hashfunc PyTypeObject.tp_hash
|
.. c:member:: hashfunc PyTypeObject.tp_hash
|
||||||
|
|
||||||
.. index:: builtin: hash
|
.. index:: pair: built-in function; hash
|
||||||
|
|
||||||
An optional pointer to a function that implements the built-in function
|
An optional pointer to a function that implements the built-in function
|
||||||
:func:`hash`.
|
:func:`hash`.
|
||||||
|
|
|
@ -149,7 +149,7 @@ done. This can be done using the :c:func:`PyErr_Fetch` and
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
single: string; object representation
|
single: string; object representation
|
||||||
builtin: repr
|
pair: built-in function; repr
|
||||||
|
|
||||||
Object Presentation
|
Object Presentation
|
||||||
-------------------
|
-------------------
|
||||||
|
|
|
@ -1367,7 +1367,7 @@ iterations of the loop.
|
||||||
|
|
||||||
.. opcode:: BUILD_SLICE (argc)
|
.. opcode:: BUILD_SLICE (argc)
|
||||||
|
|
||||||
.. index:: builtin: slice
|
.. index:: pair: built-in function; slice
|
||||||
|
|
||||||
Pushes a slice object on the stack. *argc* must be 2 or 3. If it is 2, implements::
|
Pushes a slice object on the stack. *argc* must be 2 or 3. If it is 2, implements::
|
||||||
|
|
||||||
|
|
|
@ -562,7 +562,7 @@ are always available. They are listed here in alphabetical order.
|
||||||
Raises an :ref:`auditing event <auditing>` ``exec`` with the code object
|
Raises an :ref:`auditing event <auditing>` ``exec`` with the code object
|
||||||
as the argument. Code compilation events may also be raised.
|
as the argument. Code compilation events may also be raised.
|
||||||
|
|
||||||
.. index:: builtin: exec
|
.. index:: pair: built-in function; exec
|
||||||
|
|
||||||
.. function:: exec(object, globals=None, locals=None, /, *, closure=None)
|
.. function:: exec(object, globals=None, locals=None, /, *, closure=None)
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ The :mod:`pprint` module defines one class:
|
||||||
|
|
||||||
.. function:: isreadable(object)
|
.. function:: isreadable(object)
|
||||||
|
|
||||||
.. index:: builtin: eval
|
.. index:: pair: built-in function; eval
|
||||||
|
|
||||||
Determine if the formatted representation of *object* is "readable", or can be
|
Determine if the formatted representation of *object* is "readable", or can be
|
||||||
used to reconstruct the value using :func:`eval`. This always returns ``False``
|
used to reconstruct the value using :func:`eval`. This always returns ``False``
|
||||||
|
@ -218,7 +218,7 @@ created.
|
||||||
|
|
||||||
.. method:: PrettyPrinter.isreadable(object)
|
.. method:: PrettyPrinter.isreadable(object)
|
||||||
|
|
||||||
.. index:: builtin: eval
|
.. index:: pair: built-in function; eval
|
||||||
|
|
||||||
Determine if the formatted representation of the object is "readable," or can be
|
Determine if the formatted representation of the object is "readable," or can be
|
||||||
used to reconstruct the value using :func:`eval`. Note that this returns
|
used to reconstruct the value using :func:`eval`. Note that this returns
|
||||||
|
|
|
@ -244,9 +244,9 @@ and imaginary parts.
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
single: arithmetic
|
single: arithmetic
|
||||||
builtin: int
|
pair: built-in function; int
|
||||||
builtin: float
|
pair: built-in function; float
|
||||||
builtin: complex
|
pair: built-in function; complex
|
||||||
single: operator; + (plus)
|
single: operator; + (plus)
|
||||||
single: + (plus); unary operator
|
single: + (plus); unary operator
|
||||||
single: + (plus); binary operator
|
single: + (plus); binary operator
|
||||||
|
@ -945,9 +945,9 @@ operations have the same priority as the corresponding numeric operations. [3]_
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
triple: operations on; sequence; types
|
triple: operations on; sequence; types
|
||||||
builtin: len
|
pair: built-in function; len
|
||||||
builtin: min
|
pair: built-in function; min
|
||||||
builtin: max
|
pair: built-in function; max
|
||||||
pair: concatenation; operation
|
pair: concatenation; operation
|
||||||
pair: repetition; operation
|
pair: repetition; operation
|
||||||
pair: subscript; operation
|
pair: subscript; operation
|
||||||
|
@ -1113,7 +1113,7 @@ Immutable Sequence Types
|
||||||
.. index::
|
.. index::
|
||||||
triple: immutable; sequence; types
|
triple: immutable; sequence; types
|
||||||
pair: object; tuple
|
pair: object; tuple
|
||||||
builtin: hash
|
pair: built-in function; hash
|
||||||
|
|
||||||
The only operation that immutable sequence types generally implement that is
|
The only operation that immutable sequence types generally implement that is
|
||||||
not also implemented by mutable sequence types is support for the :func:`hash`
|
not also implemented by mutable sequence types is support for the :func:`hash`
|
||||||
|
@ -4419,7 +4419,7 @@ Mapping Types --- :class:`dict`
|
||||||
triple: operations on; mapping; types
|
triple: operations on; mapping; types
|
||||||
triple: operations on; dictionary; type
|
triple: operations on; dictionary; type
|
||||||
pair: statement; del
|
pair: statement; del
|
||||||
builtin: len
|
pair: built-in function; len
|
||||||
|
|
||||||
A :term:`mapping` object maps :term:`hashable` values to arbitrary objects.
|
A :term:`mapping` object maps :term:`hashable` values to arbitrary objects.
|
||||||
Mappings are mutable objects. There is currently only one standard mapping
|
Mappings are mutable objects. There is currently only one standard mapping
|
||||||
|
@ -5348,7 +5348,7 @@ Code Objects
|
||||||
------------
|
------------
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
builtin: compile
|
pair: built-in function; compile
|
||||||
single: __code__ (function object attribute)
|
single: __code__ (function object attribute)
|
||||||
|
|
||||||
Code objects are used by the implementation to represent "pseudo-compiled"
|
Code objects are used by the implementation to represent "pseudo-compiled"
|
||||||
|
@ -5362,8 +5362,8 @@ Accessing ``__code__`` raises an :ref:`auditing event <auditing>`
|
||||||
``object.__getattr__`` with arguments ``obj`` and ``"__code__"``.
|
``object.__getattr__`` with arguments ``obj`` and ``"__code__"``.
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
builtin: exec
|
pair: built-in function; exec
|
||||||
builtin: eval
|
pair: built-in function; eval
|
||||||
|
|
||||||
A code object can be executed or evaluated by passing it (instead of a source
|
A code object can be executed or evaluated by passing it (instead of a source
|
||||||
string) to the :func:`exec` or :func:`eval` built-in functions.
|
string) to the :func:`exec` or :func:`eval` built-in functions.
|
||||||
|
@ -5377,7 +5377,7 @@ Type Objects
|
||||||
------------
|
------------
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
builtin: type
|
pair: built-in function; type
|
||||||
pair: module; types
|
pair: module; types
|
||||||
|
|
||||||
Type objects represent the various object types. An object's type is accessed
|
Type objects represent the various object types. An object's type is accessed
|
||||||
|
|
|
@ -186,7 +186,7 @@ Standard names are defined for the following types:
|
||||||
|
|
||||||
.. class:: CodeType(**kwargs)
|
.. class:: CodeType(**kwargs)
|
||||||
|
|
||||||
.. index:: builtin: compile
|
.. index:: pair: built-in function; compile
|
||||||
|
|
||||||
The type for code objects such as returned by :func:`compile`.
|
The type for code objects such as returned by :func:`compile`.
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,7 @@ those made in the suite of the for-loop::
|
||||||
|
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
builtin: range
|
pair: built-in function; range
|
||||||
|
|
||||||
Names in the target list are not deleted when the loop is finished, but if the
|
Names in the target list are not deleted when the loop is finished, but if the
|
||||||
sequence is empty, they will not have been assigned to at all by the loop. Hint:
|
sequence is empty, they will not have been assigned to at all by the loop. Hint:
|
||||||
|
|
|
@ -21,8 +21,8 @@ conformance to Von Neumann's model of a "stored program computer", code is also
|
||||||
represented by objects.)
|
represented by objects.)
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
builtin: id
|
pair: built-in function; id
|
||||||
builtin: type
|
pair: built-in function; type
|
||||||
single: identity of an object
|
single: identity of an object
|
||||||
single: value of an object
|
single: value of an object
|
||||||
single: type of an object
|
single: type of an object
|
||||||
|
@ -267,7 +267,7 @@ Ellipsis
|
||||||
|
|
||||||
Sequences
|
Sequences
|
||||||
.. index::
|
.. index::
|
||||||
builtin: len
|
pair: built-in function; len
|
||||||
pair: object; sequence
|
pair: object; sequence
|
||||||
single: index operation
|
single: index operation
|
||||||
single: item selection
|
single: item selection
|
||||||
|
@ -308,8 +308,8 @@ Sequences
|
||||||
|
|
||||||
Strings
|
Strings
|
||||||
.. index::
|
.. index::
|
||||||
builtin: chr
|
pair: built-in function; chr
|
||||||
builtin: ord
|
pair: built-in function; ord
|
||||||
single: character
|
single: character
|
||||||
single: integer
|
single: integer
|
||||||
single: Unicode
|
single: Unicode
|
||||||
|
@ -384,7 +384,7 @@ Sequences
|
||||||
|
|
||||||
Set types
|
Set types
|
||||||
.. index::
|
.. index::
|
||||||
builtin: len
|
pair: built-in function; len
|
||||||
pair: object; set type
|
pair: object; set type
|
||||||
|
|
||||||
These represent unordered, finite sets of unique, immutable objects. As such,
|
These represent unordered, finite sets of unique, immutable objects. As such,
|
||||||
|
@ -418,7 +418,7 @@ Set types
|
||||||
|
|
||||||
Mappings
|
Mappings
|
||||||
.. index::
|
.. index::
|
||||||
builtin: len
|
pair: built-in function; len
|
||||||
single: subscription
|
single: subscription
|
||||||
pair: object; mapping
|
pair: object; mapping
|
||||||
|
|
||||||
|
@ -908,7 +908,7 @@ Class instances
|
||||||
|
|
||||||
I/O objects (also known as file objects)
|
I/O objects (also known as file objects)
|
||||||
.. index::
|
.. index::
|
||||||
builtin: open
|
pair: built-in function; open
|
||||||
pair: module; io
|
pair: module; io
|
||||||
single: popen() (in module os)
|
single: popen() (in module os)
|
||||||
single: makefile() (socket method)
|
single: makefile() (socket method)
|
||||||
|
@ -1177,7 +1177,7 @@ Internal types
|
||||||
and the ``tb_next`` attribute of existing instances can be updated.
|
and the ``tb_next`` attribute of existing instances can be updated.
|
||||||
|
|
||||||
Slice objects
|
Slice objects
|
||||||
.. index:: builtin: slice
|
.. index:: pair: built-in function; slice
|
||||||
|
|
||||||
Slice objects are used to represent slices for
|
Slice objects are used to represent slices for
|
||||||
:meth:`~object.__getitem__`
|
:meth:`~object.__getitem__`
|
||||||
|
@ -1411,7 +1411,7 @@ Basic customization
|
||||||
|
|
||||||
.. method:: object.__bytes__(self)
|
.. method:: object.__bytes__(self)
|
||||||
|
|
||||||
.. index:: builtin: bytes
|
.. index:: pair: built-in function; bytes
|
||||||
|
|
||||||
Called by :ref:`bytes <func-bytes>` to compute a byte-string representation
|
Called by :ref:`bytes <func-bytes>` to compute a byte-string representation
|
||||||
of an object. This should return a :class:`bytes` object.
|
of an object. This should return a :class:`bytes` object.
|
||||||
|
@ -1419,7 +1419,7 @@ Basic customization
|
||||||
.. index::
|
.. index::
|
||||||
single: string; __format__() (object method)
|
single: string; __format__() (object method)
|
||||||
pair: string; conversion
|
pair: string; conversion
|
||||||
builtin: print
|
pair: built-in function; print
|
||||||
|
|
||||||
|
|
||||||
.. method:: object.__format__(self, format_spec)
|
.. method:: object.__format__(self, format_spec)
|
||||||
|
@ -1499,7 +1499,7 @@ Basic customization
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
pair: object; dictionary
|
pair: object; dictionary
|
||||||
builtin: hash
|
pair: built-in function; hash
|
||||||
|
|
||||||
Called by built-in function :func:`hash` and for operations on members of
|
Called by built-in function :func:`hash` and for operations on members of
|
||||||
hashed collections including :class:`set`, :class:`frozenset`, and
|
hashed collections including :class:`set`, :class:`frozenset`, and
|
||||||
|
@ -2050,7 +2050,7 @@ Metaclasses
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
single: metaclass
|
single: metaclass
|
||||||
builtin: type
|
pair: built-in function; type
|
||||||
single: = (equals); class definition
|
single: = (equals); class definition
|
||||||
|
|
||||||
By default, classes are constructed using :func:`type`. The class body is
|
By default, classes are constructed using :func:`type`. The class body is
|
||||||
|
@ -2477,7 +2477,7 @@ through the object's keys; for sequences, it should iterate through the values.
|
||||||
.. method:: object.__len__(self)
|
.. method:: object.__len__(self)
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
builtin: len
|
pair: built-in function; len
|
||||||
single: __bool__() (object method)
|
single: __bool__() (object method)
|
||||||
|
|
||||||
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
|
||||||
|
@ -2635,9 +2635,9 @@ left undefined.
|
||||||
object.__or__(self, other)
|
object.__or__(self, other)
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
builtin: divmod
|
pair: built-in function; divmod
|
||||||
builtin: pow
|
pair: built-in function; pow
|
||||||
builtin: pow
|
pair: built-in function; pow
|
||||||
|
|
||||||
These methods are called to implement the binary arithmetic operations
|
These methods are called to implement the binary arithmetic operations
|
||||||
(``+``, ``-``, ``*``, ``@``, ``/``, ``//``, ``%``, :func:`divmod`,
|
(``+``, ``-``, ``*``, ``@``, ``/``, ``//``, ``%``, :func:`divmod`,
|
||||||
|
@ -2670,8 +2670,8 @@ left undefined.
|
||||||
object.__ror__(self, other)
|
object.__ror__(self, other)
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
builtin: divmod
|
pair: built-in function; divmod
|
||||||
builtin: pow
|
pair: built-in function; pow
|
||||||
|
|
||||||
These methods are called to implement the binary arithmetic operations
|
These methods are called to implement the binary arithmetic operations
|
||||||
(``+``, ``-``, ``*``, ``@``, ``/``, ``//``, ``%``, :func:`divmod`,
|
(``+``, ``-``, ``*``, ``@``, ``/``, ``//``, ``%``, :func:`divmod`,
|
||||||
|
@ -2683,7 +2683,7 @@ left undefined.
|
||||||
``type(y).__rsub__(y, x)`` is called if ``type(x).__sub__(x, y)`` returns
|
``type(y).__rsub__(y, x)`` is called if ``type(x).__sub__(x, y)`` returns
|
||||||
*NotImplemented*.
|
*NotImplemented*.
|
||||||
|
|
||||||
.. index:: builtin: pow
|
.. index:: pair: built-in function; pow
|
||||||
|
|
||||||
Note that ternary :func:`pow` will not try calling :meth:`__rpow__` (the
|
Note that ternary :func:`pow` will not try calling :meth:`__rpow__` (the
|
||||||
coercion rules would become too complicated).
|
coercion rules would become too complicated).
|
||||||
|
@ -2730,7 +2730,7 @@ left undefined.
|
||||||
object.__abs__(self)
|
object.__abs__(self)
|
||||||
object.__invert__(self)
|
object.__invert__(self)
|
||||||
|
|
||||||
.. index:: builtin: abs
|
.. index:: pair: built-in function; abs
|
||||||
|
|
||||||
Called to implement the unary arithmetic operations (``-``, ``+``, :func:`abs`
|
Called to implement the unary arithmetic operations (``-``, ``+``, :func:`abs`
|
||||||
and ``~``).
|
and ``~``).
|
||||||
|
@ -2741,9 +2741,9 @@ left undefined.
|
||||||
object.__float__(self)
|
object.__float__(self)
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
builtin: complex
|
pair: built-in function; complex
|
||||||
builtin: int
|
pair: built-in function; int
|
||||||
builtin: float
|
pair: built-in function; float
|
||||||
|
|
||||||
Called to implement the built-in functions :func:`complex`,
|
Called to implement the built-in functions :func:`complex`,
|
||||||
:func:`int` and :func:`float`. Should return a value
|
:func:`int` and :func:`float`. Should return a value
|
||||||
|
@ -2768,7 +2768,7 @@ left undefined.
|
||||||
object.__floor__(self)
|
object.__floor__(self)
|
||||||
object.__ceil__(self)
|
object.__ceil__(self)
|
||||||
|
|
||||||
.. index:: builtin: round
|
.. index:: pair: built-in function; round
|
||||||
|
|
||||||
Called to implement the built-in function :func:`round` and :mod:`math`
|
Called to implement the built-in function :func:`round` and :mod:`math`
|
||||||
functions :func:`~math.trunc`, :func:`~math.floor` and :func:`~math.ceil`.
|
functions :func:`~math.trunc`, :func:`~math.floor` and :func:`~math.ceil`.
|
||||||
|
|
|
@ -53,7 +53,7 @@ An expression statement evaluates the expression list (which may be a single
|
||||||
expression).
|
expression).
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
builtin: repr
|
pair: built-in function; repr
|
||||||
pair: object; None
|
pair: object; None
|
||||||
pair: string; conversion
|
pair: string; conversion
|
||||||
single: output
|
single: output
|
||||||
|
@ -970,9 +970,9 @@ annotation.
|
||||||
them or silently change the meaning of the program.
|
them or silently change the meaning of the program.
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
builtin: exec
|
pair: built-in function; exec
|
||||||
builtin: eval
|
pair: built-in function; eval
|
||||||
builtin: compile
|
pair: built-in function; compile
|
||||||
|
|
||||||
**Programmer's note:** :keyword:`global` is a directive to the parser. It
|
**Programmer's note:** :keyword:`global` is a directive to the parser. It
|
||||||
applies only to code parsed at the same time as the :keyword:`!global` statement.
|
applies only to code parsed at the same time as the :keyword:`!global` statement.
|
||||||
|
|
|
@ -98,7 +98,7 @@ Expression input
|
||||||
================
|
================
|
||||||
|
|
||||||
.. index:: single: input
|
.. index:: single: input
|
||||||
.. index:: builtin: eval
|
.. index:: pair: built-in function; eval
|
||||||
|
|
||||||
:func:`eval` is used for expression input. It ignores leading whitespace. The
|
:func:`eval` is used for expression input. It ignores leading whitespace. The
|
||||||
string argument to :func:`eval` must have the following form:
|
string argument to :func:`eval` must have the following form:
|
||||||
|
|
|
@ -695,7 +695,7 @@ def patch_pairindextypes(app) -> None:
|
||||||
pairindextypes.pop('object', None)
|
pairindextypes.pop('object', None)
|
||||||
pairindextypes.pop('exception', None)
|
pairindextypes.pop('exception', None)
|
||||||
pairindextypes.pop('statement', None)
|
pairindextypes.pop('statement', None)
|
||||||
# pairindextypes.pop('builtin', None)
|
pairindextypes.pop('builtin', None)
|
||||||
|
|
||||||
|
|
||||||
def setup(app):
|
def setup(app):
|
||||||
|
|
|
@ -285,7 +285,7 @@ Reading and Writing Files
|
||||||
=========================
|
=========================
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
builtin: open
|
pair: built-in function; open
|
||||||
pair: object; file
|
pair: object; file
|
||||||
|
|
||||||
:func:`open` returns a :term:`file object`, and is most commonly used with
|
:func:`open` returns a :term:`file object`, and is most commonly used with
|
||||||
|
|
|
@ -24,7 +24,7 @@ Be sure to use the ``import os`` style instead of ``from os import *``. This
|
||||||
will keep :func:`os.open` from shadowing the built-in :func:`open` function which
|
will keep :func:`os.open` from shadowing the built-in :func:`open` function which
|
||||||
operates much differently.
|
operates much differently.
|
||||||
|
|
||||||
.. index:: builtin: help
|
.. index:: pair: built-in function; help
|
||||||
|
|
||||||
The built-in :func:`dir` and :func:`help` functions are useful as interactive
|
The built-in :func:`dir` and :func:`help` functions are useful as interactive
|
||||||
aids for working with large modules like :mod:`os`::
|
aids for working with large modules like :mod:`os`::
|
||||||
|
|
Loading…
Reference in New Issue