8000 GH-97950: Use new-style index directive ('operator') by AA-Turner · Pull Request #104156 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-97950: Use new-style index directive ('operator') #104156

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
56 changes: 28 additions & 28 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ objects considered false:
``range(0)``

.. index::
operator: or
operator: and
pair: operator; or
pair: operator; and
single: False
single: True

Expand Down Expand Up @@ -95,9 +95,9 @@ These are the Boolean operations, ordered by ascending priority:
+-------------+---------------------------------+-------+

.. index::
operator: and
operator: or
operator: not
pair: operator; and
pair: operator; or
pair: operator; not

Notes:

Expand All @@ -122,14 +122,14 @@ Comparisons
.. index::
pair: chaining; comparisons
pair: operator; comparison
operator: ==
operator: < (less)
operator: <=
operator: > (greater)
operator: >=
operator: !=
operator: is
operator: is not
pair: operator; ==
pair: operator; < (less)
pair: operator; <=
pair: operator; > (greater)
pair: operator; >=
pair: operator; !=
pair: operator; is
pair: operator; is not

There are eight comparison operations in Python. They all have the same
priority (which is higher than that of the Boolean operations). Comparisons can
Expand Down Expand Up @@ -192,8 +192,8 @@ customized; also they can be applied to any two objects and never raise an
exception.

.. index::
operator: in
operator: not in
pair: operator; in
pair: operator; not in

Two more operations with the same syntactic priority, :keyword:`in` and
:keyword:`not in`, are supported by types that are :term:`iterable` or
Expand Down Expand Up @@ -253,11 +253,11 @@ and imaginary parts.
single: operator; - (minus)
single: - (minus); unary operator
single: - (minus); binary operator
operator: * (asterisk)
operator: / (slash)
operator: //
operator: % (percent)
operator: **
pair: operator; * (asterisk)
pair: operator; / (slash)
pair: operator; //
pair: operator; % (percent)
pair: operator; **

Python fully supports mixed arithmetic: when a binary arithmetic operator has
operands of different numeric types, the operand with the "narrower" type is
Expand Down Expand Up @@ -392,12 +392,12 @@ Bitwise Operations on Integer Types
pair: bitwise; operations
pair: shifting; operations
pair: masking; operations
operator: | (vertical bar)
operator: ^ (caret)
operator: & (ampersand)
operator: <<
operator: >>
operator: ~ (tilde)
pair: operator; | (vertical bar)
pair: operator; ^ (caret)
pair: operator; & (ampersand)
pair: operator; <<
pair: operator; >>
pair: operator; ~ (tilde)

Bitwise operations only make sense for integers. The result of bitwise
operations is calculated as though carried out in two's complement with an
Expand Down Expand Up @@ -952,8 +952,8 @@ operations have the same priority as the corresponding numeric operations. [3]_
pair: repetition; operation
pair: subscript; operation
pair: slice; operation
operator: in
8000 operator: not in
pair: operator; in
pair: operator; not in
single: count() (sequence method)
single: index() (sequence method)

Expand Down
50 changes: 25 additions & 25 deletions Doc/reference/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ The power operator

.. index::
pair: power; operation
operator: **
pair: operator; **

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:
Expand Down Expand Up @@ -1232,7 +1232,7 @@ operation can be overridden with the :meth:`__pos__` special method.

.. index::
single: inversion
operator: ~ (tilde)
pair: operator; ~ (tilde)

The unary ``~`` (invert) operator yields the bitwise inversion of its integer
argument. The bitwise inversion of ``x`` is defined as ``-(x+1)``. It only
Expand Down Expand Up @@ -1267,7 +1267,7 @@ operators and one for additive operators:

.. index::
single: multiplication
operator: * (asterisk)
pair: operator; * (asterisk)

The ``*`` (multiplication) operator yields the product of its arguments. The
arguments must either both be numbers, or one argument must be an integer and
Expand All @@ -1280,7 +1280,7 @@ This operation can be customized using the special :meth:`__mul__` and

.. index::
single: matrix multiplication
operator: @ (at)
pair: operator; @ (at)

The ``@`` (at) operator is intended to be used for matrix multiplication. No
builtin Python types implement this operator.
Expand All @@ -1290,8 +1290,8 @@ builtin Python types implement this operator.
.. index::
exception: ZeroDivisionError
single: division
operator: / (slash)
operator: //
pair: operator; / (slash)
pair: operator; //

The ``/`` (division) and ``//`` (floor division) operators yield the quotient of
their arguments. The numeric arguments are first converted to a common type.
Expand All @@ -1305,7 +1305,7 @@ This operation can be customized using the special :meth:`__truediv__` and

.. index::
single: modulo
operator: % (percent)
pair: operator; % (percent)

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
Expand Down Expand Up @@ -1363,8 +1363,8 @@ Shifting operations

.. index::
pair: shifting; operation
operator: <<
operator: >>
pair: operator; <<
pair: operator; >>

The shifting operations have lower priority than the arithmetic operations:

Expand Down Expand Up @@ -1399,7 +1399,7 @@ Each of the three bitwise operations has a different priority level:

.. index::
pair: bitwise; and
operator: & (ampersand)
pair: operator; & (ampersand)

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
Expand All @@ -1408,7 +1408,7 @@ integers or one of them must be a custom object overriding :meth:`__and__` or
.. index::
pair: bitwise; xor
pair: exclusive; or
operator: ^ (caret)
pair: operator; ^ (caret)

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
Expand All @@ -1417,7 +1417,7 @@ must be integers or one of them must be a custom object overriding :meth:`__xor_
.. index::
pair: bitwise; or
pair: inclusive; or
operator: | (vertical bar)
pair: operator; | (vertical bar)

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
Expand All @@ -1432,12 +1432,12 @@ Comparisons
.. index::
single: comparison
pair: C; language
operator: < (less)
operator: > (greater)
operator: <=
operator: >=
operator: ==
operator: !=
pair: operator; < (less)
pair: operator; > (greater)
pair: operator; <=
pair: operator; >=
pair: operator; ==
pair: operator; !=

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
Expand Down Expand Up @@ -1669,17 +1669,17 @@ raises the :exc:`IndexError` exception. (If any other exception is raised, it i
if :keyword:`in` raised that exception).

.. index::
operator: in
operator: not in
pair: operator; in
pair: operator; not in
pair: membership; test
object: sequence

The operator :keyword:`not in` is defined to have the inverse truth value of
:keyword:`in`.

.. index::
operator: is
operator: is not
pair: operator; is
pair: operator; is not
pair: identity; test


Expand Down Expand Up @@ -1719,17 +1719,17 @@ control flow statements, the following values are interpreted as false:
other values are interpreted as true. User-defined objects can customize their
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``
otherwise.

.. index:: operator: and
.. index:: pair: operator; and

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.

.. index:: operator: or
.. index:: pair: operator; or

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.
Expand Down
2 changes: 1 addition & 1 deletion Doc/tools/extensions/pyspecific.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ def patch_pairindextypes(app) -> None:

pairindextypes.pop('module', None)
pairindextypes.pop('keyword', None)
# pairindextypes.pop('operator', None)
pairindextypes.pop('operator', None)
# pairindextypes.pop('object', None)
# pairindextypes.pop('exception', None)
# pairindextypes.pop('statement', None)
Expand Down
0