summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-11-04 07:38:12 (GMT)
committerGeorg Brandl <georg@python.org>2009-11-04 07:38:12 (GMT)
commitefc285880c4fbc3adaad03d667b46702327a95e4 (patch)
tree902f3e041d9b05bd867f9b36c4a5214a5adc6fa4 /Doc/library
parent4ac6b93c002dbce511848855a0852734545ec072 (diff)
downloadcpython-efc285880c4fbc3adaad03d667b46702327a95e4.zip
cpython-efc285880c4fbc3adaad03d667b46702327a95e4.tar.gz
cpython-efc285880c4fbc3adaad03d667b46702327a95e4.tar.bz2
#7259: show correct equivalent for operator.i* operations in docstring; fix minor issues in operator docs.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/operator.rst176
1 files changed, 89 insertions, 87 deletions
diff --git a/Doc/library/operator.rst b/Doc/library/operator.rst
index 18747bb..20a82bd 100644
--- a/Doc/library/operator.rst
+++ b/Doc/library/operator.rst
@@ -117,6 +117,14 @@ The mathematical and bitwise operations are the most numerous:
.. versionadded:: 2.2
+.. function:: index(a)
+ __index__(a)
+
+ Return *a* converted to an integer. Equivalent to ``a.__index__()``.
+
+ .. versionadded:: 2.5
+
+
.. function:: inv(obj)
invert(obj)
__inv__(obj)
@@ -149,7 +157,7 @@ The mathematical and bitwise operations are the most numerous:
.. function:: neg(obj)
__neg__(obj)
- Return *obj* negated.
+ Return *obj* negated (``-obj``).
.. function:: or_(a, b)
@@ -161,7 +169,7 @@ The mathematical and bitwise operations are the most numerous:
.. function:: pos(obj)
__pos__(obj)
- Return *obj* positive.
+ Return *obj* positive (``+obj``).
.. function:: pow(a, b)
@@ -199,15 +207,7 @@ The mathematical and bitwise operations are the most numerous:
Return the bitwise exclusive or of *a* and *b*.
-.. function:: index(a)
- __index__(a)
-
- Return *a* converted to an integer. Equivalent to ``a.__index__()``.
-
- .. versionadded:: 2.5
-
-
-Operations which work with sequences include:
+Operations which work with sequences (some of them with mappings too) include:
.. function:: concat(a, b)
__concat__(a, b)
@@ -359,7 +359,7 @@ example, the :term:`statement` ``x += y`` is equivalent to
.. function:: ilshift(a, b)
__ilshift__(a, b)
- ``a = ilshift(a, b)`` is equivalent to ``a <``\ ``<= b``.
+ ``a = ilshift(a, b)`` is equivalent to ``a <<= b``.
.. versionadded:: 2.5
@@ -572,79 +572,81 @@ Mapping Operators to Functions
This table shows how abstract operations correspond to operator symbols in the
Python syntax and the functions in the :mod:`operator` module.
-+-----------------------+-------------------------+---------------------------------+
-| Operation | Syntax | Function |
-+=======================+=========================+=================================+
-| Addition | ``a + b`` | ``add(a, b)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Concatenation | ``seq1 + seq2`` | ``concat(seq1, seq2)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Containment Test | ``obj in seq`` | ``contains(seq, obj)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Division | ``a / b`` | ``div(a, b)`` (without |
-| | | ``__future__.division``) |
-+-----------------------+-------------------------+---------------------------------+
-| Division | ``a / b`` | ``truediv(a, b)`` (with |
-| | | ``__future__.division``) |
-+-----------------------+-------------------------+---------------------------------+
-| Division | ``a // b`` | ``floordiv(a, b)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Bitwise And | ``a & b`` | ``and_(a, b)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Bitwise Exclusive Or | ``a ^ b`` | ``xor(a, b)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Bitwise Inversion | ``~ a`` | ``invert(a)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Bitwise Or | ``a | b`` | ``or_(a, b)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Exponentiation | ``a ** b`` | ``pow(a, b)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Identity | ``a is b`` | ``is_(a, b)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Identity | ``a is not b`` | ``is_not(a, b)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Indexed Assignment | ``obj[k] = v`` | ``setitem(obj, k, v)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Indexed Deletion | ``del obj[k]`` | ``delitem(obj, k)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Indexing | ``obj[k]`` | ``getitem(obj, k)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Left Shift | ``a << b`` | ``lshift(a, b)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Modulo | ``a % b`` | ``mod(a, b)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Multiplication | ``a * b`` | ``mul(a, b)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Negation (Arithmetic) | ``- a`` | ``neg(a)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Negation (Logical) | ``not a`` | ``not_(a)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Right Shift | ``a >> b`` | ``rshift(a, b)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Sequence Repetition | ``seq * i`` | ``repeat(seq, i)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Slice Assignment | ``seq[i:j] = values`` | ``setslice(seq, i, j, values)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Slice Deletion | ``del seq[i:j]`` | ``delslice(seq, i, j)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Slicing | ``seq[i:j]`` | ``getslice(seq, i, j)`` |
-+-----------------------+-------------------------+---------------------------------+
-| String Formatting | ``s % obj`` | ``mod(s, obj)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Subtraction | ``a - b`` | ``sub(a, b)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Truth Test | ``obj`` | ``truth(obj)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Ordering | ``a < b`` | ``lt(a, b)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Ordering | ``a <= b`` | ``le(a, b)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Equality | ``a == b`` | ``eq(a, b)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Difference | ``a != b`` | ``ne(a, b)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Ordering | ``a >= b`` | ``ge(a, b)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Ordering | ``a > b`` | ``gt(a, b)`` |
-+-----------------------+-------------------------+---------------------------------+
++-----------------------+-------------------------+---------------------------------------+
+| Operation | Syntax | Function |
++=======================+=========================+=======================================+
+| Addition | ``a + b`` | ``add(a, b)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Concatenation | ``seq1 + seq2`` | ``concat(seq1, seq2)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Containment Test | ``obj in seq`` | ``contains(seq, obj)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Division | ``a / b`` | ``div(a, b)`` (without |
+| | | ``__future__.division``) |
++-----------------------+-------------------------+---------------------------------------+
+| Division | ``a / b`` | ``truediv(a, b)`` (with |
+| | | ``__future__.division``) |
++-----------------------+-------------------------+---------------------------------------+
+| Division | ``a // b`` | ``floordiv(a, b)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Bitwise And | ``a & b`` | ``and_(a, b)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Bitwise Exclusive Or | ``a ^ b`` | ``xor(a, b)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Bitwise Inversion | ``~ a`` | ``invert(a)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Bitwise Or | ``a | b`` | ``or_(a, b)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Exponentiation | ``a ** b`` | ``pow(a, b)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Identity | ``a is b`` | ``is_(a, b)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Identity | ``a is not b`` | ``is_not(a, b)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Indexed Assignment | ``obj[k] = v`` | ``setitem(obj, k, v)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Indexed Deletion | ``del obj[k]`` | ``delitem(obj, k)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Indexing | ``obj[k]`` | ``getitem(obj, k)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Left Shift | ``a << b`` | ``lshift(a, b)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Modulo | ``a % b`` | ``mod(a, b)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Multiplication | ``a * b`` | ``mul(a, b)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Negation (Arithmetic) | ``- a`` | ``neg(a)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Negation (Logical) | ``not a`` | ``not_(a)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Positive | ``+ a`` | ``pos(a)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Right Shift | ``a >> b`` | ``rshift(a, b)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Sequence Repetition | ``seq * i`` | ``repeat(seq, i)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Slice Assignment | ``seq[i:j] = values`` | ``setitem(seq, slice(i, j), values)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Slice Deletion | ``del seq[i:j]`` | ``delitem(seq, slice(i, j))`` |
++-----------------------+-------------------------+---------------------------------------+
+| Slicing | ``seq[i:j]`` | ``getitem(seq, slice(i, j))`` |
++-----------------------+-------------------------+---------------------------------------+
+| String Formatting | ``s % obj`` | ``mod(s, obj)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Subtraction | ``a - b`` | ``sub(a, b)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Truth Test | ``obj`` | ``truth(obj)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Ordering | ``a < b`` | ``lt(a, b)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Ordering | ``a <= b`` | ``le(a, b)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Equality | ``a == b`` | ``eq(a, b)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Difference | ``a != b`` | ``ne(a, b)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Ordering | ``a >= b`` | ``ge(a, b)`` |
++-----------------------+-------------------------+---------------------------------------+
+| Ordering | ``a > b`` | ``gt(a, b)`` |
++-----------------------+-------------------------+---------------------------------------+