mirror of
https://github.com/python/cpython.git
synced 2025-08-15 14:20:55 +00:00
[3.11] GH-97950: Use new-style index directive ('operator') (GH-104156) (#104157)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
This commit is contained in:
parent
a9fcf01ed9
commit
693ef48df1
3 changed files with 54 additions and 54 deletions
|
@ -61,8 +61,8 @@ objects considered false:
|
||||||
``range(0)``
|
``range(0)``
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
operator: or
|
pair: operator; or
|
||||||
operator: and
|
pair: operator; and
|
||||||
single: False
|
single: False
|
||||||
single: True
|
single: True
|
||||||
|
|
||||||
|
@ -95,9 +95,9 @@ These are the Boolean operations, ordered by ascending priority:
|
||||||
+-------------+---------------------------------+-------+
|
+-------------+---------------------------------+-------+
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
operator: and
|
pair: operator; and
|
||||||
operator: or
|
pair: operator; or
|
||||||
operator: not
|
pair: operator; not
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
|
|
||||||
|
@ -122,14 +122,14 @@ Comparisons
|
||||||
.. index::
|
.. index::
|
||||||
pair: chaining; comparisons
|
pair: chaining; comparisons
|
||||||
pair: operator; comparison
|
pair: operator; comparison
|
||||||
operator: ==
|
pair: operator; ==
|
||||||
operator: < (less)
|
pair: operator; < (less)
|
||||||
operator: <=
|
pair: operator; <=
|
||||||
operator: > (greater)
|
pair: operator; > (greater)
|
||||||
operator: >=
|
pair: operator; >=
|
||||||
operator: !=
|
pair: operator; !=
|
||||||
operator: is
|
pair: operator; is
|
||||||
operator: is not
|
pair: operator; is not
|
||||||
|
|
||||||
There are eight comparison operations in Python. They all have the same
|
There are eight comparison operations in Python. They all have the same
|
||||||
priority (which is higher than that of the Boolean operations). Comparisons can
|
priority (which is higher than that of the Boolean operations). Comparisons can
|
||||||
|
@ -192,8 +192,8 @@ customized; also they can be applied to any two objects and never raise an
|
||||||
exception.
|
exception.
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
operator: in
|
pair: operator; in
|
||||||
operator: not in
|
pair: operator; not in
|
||||||
|
|
||||||
Two more operations with the same syntactic priority, :keyword:`in` and
|
Two more operations with the same syntactic priority, :keyword:`in` and
|
||||||
:keyword:`not in`, are supported by types that are :term:`iterable` or
|
:keyword:`not in`, are supported by types that are :term:`iterable` or
|
||||||
|
@ -253,11 +253,11 @@ and imaginary parts.
|
||||||
single: operator; - (minus)
|
single: operator; - (minus)
|
||||||
single: - (minus); unary operator
|
single: - (minus); unary operator
|
||||||
single: - (minus); binary operator
|
single: - (minus); binary operator
|
||||||
operator: * (asterisk)
|
pair: operator; * (asterisk)
|
||||||
operator: / (slash)
|
pair: operator; / (slash)
|
||||||
operator: //
|
pair: operator; //
|
||||||
operator: % (percent)
|
pair: operator; % (percent)
|
||||||
operator: **
|
pair: operator; **
|
||||||
|
|
||||||
Python fully supports mixed arithmetic: when a binary arithmetic operator has
|
Python fully supports mixed arithmetic: when a binary arithmetic operator has
|
||||||
operands of different numeric types, the operand with the "narrower" type is
|
operands of different numeric types, the operand with the "narrower" type is
|
||||||
|
@ -392,12 +392,12 @@ Bitwise Operations on Integer Types
|
||||||
pair: bitwise; operations
|
pair: bitwise; operations
|
||||||
pair: shifting; operations
|
pair: shifting; operations
|
||||||
pair: masking; operations
|
pair: masking; operations
|
||||||
operator: | (vertical bar)
|
pair: operator; | (vertical bar)
|
||||||
operator: ^ (caret)
|
pair: operator; ^ (caret)
|
||||||
operator: & (ampersand)
|
pair: operator; & (ampersand)
|
||||||
operator: <<
|
pair: operator; <<
|
||||||
operator: >>
|
pair: operator; >>
|
||||||
operator: ~ (tilde)
|
pair: operator; ~ (tilde)
|
||||||
|
|
||||||
Bitwise operations only make sense for integers. The result of bitwise
|
Bitwise operations only make sense for integers. The result of bitwise
|
||||||
operations is calculated as though carried out in two's complement with an
|
operations is calculated as though carried out in two's complement with an
|
||||||
|
@ -913,8 +913,8 @@ operations have the same priority as the corresponding numeric operations. [3]_
|
||||||
pair: repetition; operation
|
pair: repetition; operation
|
||||||
pair: subscript; operation
|
pair: subscript; operation
|
||||||
pair: slice; operation
|
pair: slice; operation
|
||||||
operator: in
|
pair: operator; in
|
||||||
operator: not in
|
pair: operator; not in
|
||||||
single: count() (sequence method)
|
single: count() (sequence method)
|
||||||
single: index() (sequence method)
|
single: index() (sequence method)
|
||||||
|
|
||||||
|
|
|
@ -1160,7 +1160,7 @@ The power operator
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
pair: power; operation
|
pair: power; operation
|
||||||
operator: **
|
pair: operator; **
|
||||||
|
|
||||||
The power operator binds more tightly than unary operators on its left; it binds
|
The power operator binds more tightly than unary operators on its left; it binds
|
||||||
less tightly than unary operators on its right. The syntax is:
|
less tightly than unary operators on its right. The syntax is:
|
||||||
|
@ -1221,7 +1221,7 @@ operation can be overridden with the :meth:`__pos__` special method.
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
single: inversion
|
single: inversion
|
||||||
operator: ~ (tilde)
|
pair: operator; ~ (tilde)
|
||||||
|
|
||||||
The unary ``~`` (invert) operator yields the bitwise inversion of its integer
|
The unary ``~`` (invert) operator yields the bitwise inversion of its integer
|
||||||
argument. The bitwise inversion of ``x`` is defined as ``-(x+1)``. It only
|
argument. The bitwise inversion of ``x`` is defined as ``-(x+1)``. It only
|
||||||
|
@ -1256,7 +1256,7 @@ operators and one for additive operators:
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
single: multiplication
|
single: multiplication
|
||||||
operator: * (asterisk)
|
pair: operator; * (asterisk)
|
||||||
|
|
||||||
The ``*`` (multiplication) operator yields the product of its arguments. The
|
The ``*`` (multiplication) operator yields the product of its arguments. The
|
||||||
arguments must either both be numbers, or one argument must be an integer and
|
arguments must either both be numbers, or one argument must be an integer and
|
||||||
|
@ -1269,7 +1269,7 @@ This operation can be customized using the special :meth:`__mul__` and
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
single: matrix multiplication
|
single: matrix multiplication
|
||||||
operator: @ (at)
|
pair: operator; @ (at)
|
||||||
|
|
||||||
The ``@`` (at) operator is intended to be used for matrix multiplication. No
|
The ``@`` (at) operator is intended to be used for matrix multiplication. No
|
||||||
builtin Python types implement this operator.
|
builtin Python types implement this operator.
|
||||||
|
@ -1279,8 +1279,8 @@ builtin Python types implement this operator.
|
||||||
.. index::
|
.. index::
|
||||||
exception: ZeroDivisionError
|
exception: ZeroDivisionError
|
||||||
single: division
|
single: division
|
||||||
operator: / (slash)
|
pair: operator; / (slash)
|
||||||
operator: //
|
pair: operator; //
|
||||||
|
|
||||||
The ``/`` (division) and ``//`` (floor division) operators yield the quotient of
|
The ``/`` (division) and ``//`` (floor division) operators yield the quotient of
|
||||||
their arguments. The numeric arguments are first converted to a common type.
|
their arguments. The numeric arguments are first converted to a common type.
|
||||||
|
@ -1294,7 +1294,7 @@ This operation can be customized using the special :meth:`__truediv__` and
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
single: modulo
|
single: modulo
|
||||||
operator: % (percent)
|
pair: operator; % (percent)
|
||||||
|
|
||||||
The ``%`` (modulo) operator yields the remainder from the division of the first
|
The ``%`` (modulo) operator yields the remainder from the division of the first
|
||||||
argument by the second. The numeric arguments are first converted to a common
|
argument by the second. The numeric arguments are first converted to a common
|
||||||
|
@ -1352,8 +1352,8 @@ Shifting operations
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
pair: shifting; operation
|
pair: shifting; operation
|
||||||
operator: <<
|
pair: operator; <<
|
||||||
operator: >>
|
pair: operator; >>
|
||||||
|
|
||||||
The shifting operations have lower priority than the arithmetic operations:
|
The shifting operations have lower priority than the arithmetic operations:
|
||||||
|
|
||||||
|
@ -1388,7 +1388,7 @@ Each of the three bitwise operations has a different priority level:
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
pair: bitwise; and
|
pair: bitwise; and
|
||||||
operator: & (ampersand)
|
pair: operator; & (ampersand)
|
||||||
|
|
||||||
The ``&`` operator yields the bitwise AND of its arguments, which must be
|
The ``&`` operator yields the bitwise AND of its arguments, which must be
|
||||||
integers or one of them must be a custom object overriding :meth:`__and__` or
|
integers or one of them must be a custom object overriding :meth:`__and__` or
|
||||||
|
@ -1397,7 +1397,7 @@ integers or one of them must be a custom object overriding :meth:`__and__` or
|
||||||
.. index::
|
.. index::
|
||||||
pair: bitwise; xor
|
pair: bitwise; xor
|
||||||
pair: exclusive; or
|
pair: exclusive; or
|
||||||
operator: ^ (caret)
|
pair: operator; ^ (caret)
|
||||||
|
|
||||||
The ``^`` operator yields the bitwise XOR (exclusive OR) of its arguments, which
|
The ``^`` operator yields the bitwise XOR (exclusive OR) of its arguments, which
|
||||||
must be integers or one of them must be a custom object overriding :meth:`__xor__` or
|
must be integers or one of them must be a custom object overriding :meth:`__xor__` or
|
||||||
|
@ -1406,7 +1406,7 @@ must be integers or one of them must be a custom object overriding :meth:`__xor_
|
||||||
.. index::
|
.. index::
|
||||||
pair: bitwise; or
|
pair: bitwise; or
|
||||||
pair: inclusive; or
|
pair: inclusive; or
|
||||||
operator: | (vertical bar)
|
pair: operator; | (vertical bar)
|
||||||
|
|
||||||
The ``|`` operator yields the bitwise (inclusive) OR of its arguments, which
|
The ``|`` operator yields the bitwise (inclusive) OR of its arguments, which
|
||||||
must be integers or one of them must be a custom object overriding :meth:`__or__` or
|
must be integers or one of them must be a custom object overriding :meth:`__or__` or
|
||||||
|
@ -1421,12 +1421,12 @@ Comparisons
|
||||||
.. index::
|
.. index::
|
||||||
single: comparison
|
single: comparison
|
||||||
pair: C; language
|
pair: C; language
|
||||||
operator: < (less)
|
pair: operator; < (less)
|
||||||
operator: > (greater)
|
pair: operator; > (greater)
|
||||||
operator: <=
|
pair: operator; <=
|
||||||
operator: >=
|
pair: operator; >=
|
||||||
operator: ==
|
pair: operator; ==
|
||||||
operator: !=
|
pair: operator; !=
|
||||||
|
|
||||||
Unlike C, all comparison operations in Python have the same priority, which is
|
Unlike C, all comparison operations in Python have the same priority, which is
|
||||||
lower than that of any arithmetic, shifting or bitwise operation. Also unlike
|
lower than that of any arithmetic, shifting or bitwise operation. Also unlike
|
||||||
|
@ -1658,8 +1658,8 @@ raises the :exc:`IndexError` exception. (If any other exception is raised, it i
|
||||||
if :keyword:`in` raised that exception).
|
if :keyword:`in` raised that exception).
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
operator: in
|
pair: operator; in
|
||||||
operator: not in
|
pair: operator; not in
|
||||||
pair: membership; test
|
pair: membership; test
|
||||||
object: sequence
|
object: sequence
|
||||||
|
|
||||||
|
@ -1667,8 +1667,8 @@ The operator :keyword:`not in` is defined to have the inverse truth value of
|
||||||
:keyword:`in`.
|
:keyword:`in`.
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
operator: is
|
pair: operator; is
|
||||||
operator: is not
|
pair: operator; is not
|
||||||
pair: identity; test
|
pair: identity; test
|
||||||
|
|
||||||
|
|
||||||
|
@ -1708,17 +1708,17 @@ control flow statements, the following values are interpreted as false:
|
||||||
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:`__bool__` method.
|
||||||
|
|
||||||
.. index:: operator: not
|
.. index:: pair: operator; not
|
||||||
|
|
||||||
The operator :keyword:`not` yields ``True`` if its argument is false, ``False``
|
The operator :keyword:`not` yields ``True`` if its argument is false, ``False``
|
||||||
otherwise.
|
otherwise.
|
||||||
|
|
||||||
.. index:: operator: and
|
.. index:: pair: operator; and
|
||||||
|
|
||||||
The expression ``x and y`` first evaluates *x*; if *x* is false, its value is
|
The expression ``x and y`` first evaluates *x*; if *x* is false, its value is
|
||||||
returned; otherwise, *y* is evaluated and the resulting value is returned.
|
returned; otherwise, *y* is evaluated and the resulting value is returned.
|
||||||
|
|
||||||
.. index:: operator: or
|
.. index:: pair: operator; or
|
||||||
|
|
||||||
The expression ``x or y`` first evaluates *x*; if *x* is true, its value is
|
The expression ``x or y`` first evaluates *x*; if *x* is true, its value is
|
||||||
returned; otherwise, *y* is evaluated and the resulting value is returned.
|
returned; otherwise, *y* is evaluated and the resulting value is returned.
|
||||||
|
|
|
@ -696,7 +696,7 @@ def patch_pairindextypes(app) -> None:
|
||||||
|
|
||||||
pairindextypes.pop('module', None)
|
pairindextypes.pop('module', None)
|
||||||
pairindextypes.pop('keyword', None)
|
pairindextypes.pop('keyword', None)
|
||||||
# pairindextypes.pop('operator', None)
|
pairindextypes.pop('operator', 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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue