Mercurial > cpython-lru_cache-weakref
annotate Doc/library/operator.rst @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | 5e939912f9f8 |
| children | 5885c02120f0 |
| rev | line source |
|---|---|
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
1 :mod:`operator` --- Standard operators as functions |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
2 =================================================== |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
3 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
4 .. module:: operator |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
5 :synopsis: Functions corresponding to the standard operators. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
6 .. sectionauthor:: Skip Montanaro <skip@automatrix.com> |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
7 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
8 |
|
46027
7563f4d2f36e
Make the doctests presentation-friendlier.
Georg Brandl <georg@python.org>
parents:
46012
diff
changeset
|
9 .. testsetup:: |
|
50522
ee9ced92843a
Merged revisions 68133-68134,68141-68142,68145-68146,68148-68149,68159-68162,68166,68171-68174,68179,68195-68196,68210,68214-68215,68217-68222 via svnmerge from
Georg Brandl <georg@python.org>
parents:
50065
diff
changeset
|
10 |
|
46027
7563f4d2f36e
Make the doctests presentation-friendlier.
Georg Brandl <georg@python.org>
parents:
46012
diff
changeset
|
11 import operator |
|
7563f4d2f36e
Make the doctests presentation-friendlier.
Georg Brandl <georg@python.org>
parents:
46012
diff
changeset
|
12 from operator import itemgetter |
|
7563f4d2f36e
Make the doctests presentation-friendlier.
Georg Brandl <georg@python.org>
parents:
46012
diff
changeset
|
13 |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
14 |
|
74099
5e939912f9f8
note the blinding speed of these functions
Benjamin Peterson <benjamin@python.org>
parents:
74089
diff
changeset
|
15 The :mod:`operator` module exports a set of efficient functions corresponding to |
|
5e939912f9f8
note the blinding speed of these functions
Benjamin Peterson <benjamin@python.org>
parents:
74089
diff
changeset
|
16 the intrinsic operators of Python. For example, ``operator.add(x, y)`` is |
|
74089
355466216029
don't mention implementation detail
Benjamin Peterson <benjamin@python.org>
parents:
68256
diff
changeset
|
17 equivalent to the expression ``x+y``. The function names are those used for |
|
355466216029
don't mention implementation detail
Benjamin Peterson <benjamin@python.org>
parents:
68256
diff
changeset
|
18 special class methods; variants without leading and trailing ``__`` are also |
|
355466216029
don't mention implementation detail
Benjamin Peterson <benjamin@python.org>
parents:
68256
diff
changeset
|
19 provided for convenience. |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
20 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
21 The functions fall into categories that perform object comparisons, logical |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
22 operations, mathematical operations, sequence operations, and abstract type |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
23 tests. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
24 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
25 The object comparison functions are useful for all objects, and are named after |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
26 the rich comparison operators they support: |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
27 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
28 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
29 .. function:: lt(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
30 le(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
31 eq(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
32 ne(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
33 ge(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
34 gt(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
35 __lt__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
36 __le__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
37 __eq__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
38 __ne__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
39 __ge__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
40 __gt__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
41 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
42 Perform "rich comparisons" between *a* and *b*. Specifically, ``lt(a, b)`` is |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
43 equivalent to ``a < b``, ``le(a, b)`` is equivalent to ``a <= b``, ``eq(a, |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
44 b)`` is equivalent to ``a == b``, ``ne(a, b)`` is equivalent to ``a != b``, |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
45 ``gt(a, b)`` is equivalent to ``a > b`` and ``ge(a, b)`` is equivalent to ``a |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
46 >= b``. Note that unlike the built-in :func:`cmp`, these functions can |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
47 return any value, which may or may not be interpretable as a Boolean value. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
48 See :ref:`comparisons` for more information about rich comparisons. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
49 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
50 .. versionadded:: 2.2 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
51 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
52 The logical operations are also generally applicable to all objects, and support |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
53 truth tests, identity tests, and boolean operations: |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
54 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
55 |
|
43359
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
56 .. function:: not_(obj) |
|
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
57 __not__(obj) |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
58 |
|
43359
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
59 Return the outcome of :keyword:`not` *obj*. (Note that there is no |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
60 :meth:`__not__` method for object instances; only the interpreter core defines |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
61 this operation. The result is affected by the :meth:`__nonzero__` and |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
62 :meth:`__len__` methods.) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
63 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
64 |
|
43359
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
65 .. function:: truth(obj) |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
66 |
|
43359
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
67 Return :const:`True` if *obj* is true, and :const:`False` otherwise. This is |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
68 equivalent to using the :class:`bool` constructor. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
69 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
70 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
71 .. function:: is_(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
72 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
73 Return ``a is b``. Tests object identity. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
74 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
75 .. versionadded:: 2.3 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
76 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
77 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
78 .. function:: is_not(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
79 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
80 Return ``a is not b``. Tests object identity. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
81 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
82 .. versionadded:: 2.3 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
83 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
84 The mathematical and bitwise operations are the most numerous: |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
85 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
86 |
|
43359
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
87 .. function:: abs(obj) |
|
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
88 __abs__(obj) |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
89 |
|
43359
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
90 Return the absolute value of *obj*. |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
91 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
92 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
93 .. function:: add(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
94 __add__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
95 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
96 Return ``a + b``, for *a* and *b* numbers. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
97 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
98 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
99 .. function:: and_(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
100 __and__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
101 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
102 Return the bitwise and of *a* and *b*. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
103 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
104 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
105 .. function:: div(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
106 __div__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
107 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
108 Return ``a / b`` when ``__future__.division`` is not in effect. This is |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
109 also known as "classic" division. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
110 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
111 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
112 .. function:: floordiv(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
113 __floordiv__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
114 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
115 Return ``a // b``. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
116 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
117 .. versionadded:: 2.2 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
118 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
119 |
|
59829
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
120 .. function:: index(a) |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
121 __index__(a) |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
122 |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
123 Return *a* converted to an integer. Equivalent to ``a.__index__()``. |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
124 |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
125 .. versionadded:: 2.5 |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
126 |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
127 |
|
43359
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
128 .. function:: inv(obj) |
|
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
129 invert(obj) |
|
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
130 __inv__(obj) |
|
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
131 __invert__(obj) |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
132 |
|
43359
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
133 Return the bitwise inverse of the number *obj*. This is equivalent to ``~obj``. |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
134 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
135 .. versionadded:: 2.0 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
136 The names :func:`invert` and :func:`__invert__`. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
137 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
138 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
139 .. function:: lshift(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
140 __lshift__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
141 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
142 Return *a* shifted left by *b*. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
143 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
144 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
145 .. function:: mod(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
146 __mod__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
147 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
148 Return ``a % b``. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
149 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
150 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
151 .. function:: mul(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
152 __mul__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
153 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
154 Return ``a * b``, for *a* and *b* numbers. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
155 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
156 |
|
43359
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
157 .. function:: neg(obj) |
|
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
158 __neg__(obj) |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
159 |
|
59829
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
160 Return *obj* negated (``-obj``). |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
161 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
162 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
163 .. function:: or_(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
164 __or__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
165 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
166 Return the bitwise or of *a* and *b*. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
167 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
168 |
|
43359
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
169 .. function:: pos(obj) |
|
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
170 __pos__(obj) |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
171 |
|
59829
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
172 Return *obj* positive (``+obj``). |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
173 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
174 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
175 .. function:: pow(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
176 __pow__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
177 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
178 Return ``a ** b``, for *a* and *b* numbers. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
179 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
180 .. versionadded:: 2.3 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
181 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
182 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
183 .. function:: rshift(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
184 __rshift__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
185 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
186 Return *a* shifted right by *b*. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
187 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
188 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
189 .. function:: sub(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
190 __sub__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
191 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
192 Return ``a - b``. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
193 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
194 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
195 .. function:: truediv(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
196 __truediv__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
197 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
198 Return ``a / b`` when ``__future__.division`` is in effect. This is also |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
199 known as "true" division. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
200 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
201 .. versionadded:: 2.2 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
202 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
203 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
204 .. function:: xor(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
205 __xor__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
206 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
207 Return the bitwise exclusive or of *a* and *b*. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
208 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
209 |
|
59829
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
210 Operations which work with sequences (some of them with mappings too) include: |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
211 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
212 .. function:: concat(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
213 __concat__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
214 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
215 Return ``a + b`` for *a* and *b* sequences. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
216 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
217 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
218 .. function:: contains(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
219 __contains__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
220 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
221 Return the outcome of the test ``b in a``. Note the reversed operands. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
222 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
223 .. versionadded:: 2.0 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
224 The name :func:`__contains__`. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
225 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
226 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
227 .. function:: countOf(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
228 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
229 Return the number of occurrences of *b* in *a*. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
230 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
231 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
232 .. function:: delitem(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
233 __delitem__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
234 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
235 Remove the value of *a* at index *b*. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
236 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
237 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
238 .. function:: delslice(a, b, c) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
239 __delslice__(a, b, c) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
240 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
241 Delete the slice of *a* from index *b* to index *c-1*. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
242 |
|
50065
ae98681058b2
Merged revisions 67571,67574-67576,67579-67581,67583,67591,67597,67608,67631 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47937
diff
changeset
|
243 .. deprecated:: 2.6 |
|
ae98681058b2
Merged revisions 67571,67574-67576,67579-67581,67583,67591,67597,67608,67631 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47937
diff
changeset
|
244 This function is removed in Python 3.x. Use :func:`delitem` with a slice |
|
ae98681058b2
Merged revisions 67571,67574-67576,67579-67581,67583,67591,67597,67608,67631 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47937
diff
changeset
|
245 index. |
|
ae98681058b2
Merged revisions 67571,67574-67576,67579-67581,67583,67591,67597,67608,67631 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47937
diff
changeset
|
246 |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
247 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
248 .. function:: getitem(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
249 __getitem__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
250 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
251 Return the value of *a* at index *b*. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
252 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
253 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
254 .. function:: getslice(a, b, c) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
255 __getslice__(a, b, c) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
256 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
257 Return the slice of *a* from index *b* to index *c-1*. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
258 |
|
50065
ae98681058b2
Merged revisions 67571,67574-67576,67579-67581,67583,67591,67597,67608,67631 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47937
diff
changeset
|
259 .. deprecated:: 2.6 |
|
ae98681058b2
Merged revisions 67571,67574-67576,67579-67581,67583,67591,67597,67608,67631 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47937
diff
changeset
|
260 This function is removed in Python 3.x. Use :func:`getitem` with a slice |
|
ae98681058b2
Merged revisions 67571,67574-67576,67579-67581,67583,67591,67597,67608,67631 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47937
diff
changeset
|
261 index. |
|
ae98681058b2
Merged revisions 67571,67574-67576,67579-67581,67583,67591,67597,67608,67631 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47937
diff
changeset
|
262 |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
263 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
264 .. function:: indexOf(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
265 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
266 Return the index of the first of occurrence of *b* in *a*. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
267 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
268 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
269 .. function:: repeat(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
270 __repeat__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
271 |
|
51291
7354f1afaecb
Record operator deprecations in docs.
Raymond Hettinger <python@rcn.com>
parents:
50522
diff
changeset
|
272 .. deprecated:: 2.7 |
|
7354f1afaecb
Record operator deprecations in docs.
Raymond Hettinger <python@rcn.com>
parents:
50522
diff
changeset
|
273 Use :func:`__mul__` instead. |
|
51292
7ba41c0917ff
Record operator deprecations in docs.
Raymond Hettinger <python@rcn.com>
parents:
50522
diff
changeset
|
274 |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
275 Return ``a * b`` where *a* is a sequence and *b* is an integer. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
276 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
277 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
278 .. function:: sequenceIncludes(...) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
279 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
280 .. deprecated:: 2.0 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
281 Use :func:`contains` instead. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
282 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
283 Alias for :func:`contains`. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
284 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
285 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
286 .. function:: setitem(a, b, c) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
287 __setitem__(a, b, c) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
288 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
289 Set the value of *a* at index *b* to *c*. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
290 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
291 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
292 .. function:: setslice(a, b, c, v) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
293 __setslice__(a, b, c, v) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
294 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
295 Set the slice of *a* from index *b* to index *c-1* to the sequence *v*. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
296 |
|
50065
ae98681058b2
Merged revisions 67571,67574-67576,67579-67581,67583,67591,67597,67608,67631 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47937
diff
changeset
|
297 .. deprecated:: 2.6 |
|
ae98681058b2
Merged revisions 67571,67574-67576,67579-67581,67583,67591,67597,67608,67631 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47937
diff
changeset
|
298 This function is removed in Python 3.x. Use :func:`setitem` with a slice |
|
ae98681058b2
Merged revisions 67571,67574-67576,67579-67581,67583,67591,67597,67608,67631 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47937
diff
changeset
|
299 index. |
|
ae98681058b2
Merged revisions 67571,67574-67576,67579-67581,67583,67591,67597,67608,67631 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47937
diff
changeset
|
300 |
|
51316
ce04e36f2a55
Doc fixes. Remove overbroad, redundant warnings. Fixup example code.
Raymond Hettinger <python@rcn.com>
parents:
51292
diff
changeset
|
301 Example use of operator functions:: |
|
ce04e36f2a55
Doc fixes. Remove overbroad, redundant warnings. Fixup example code.
Raymond Hettinger <python@rcn.com>
parents:
51292
diff
changeset
|
302 |
|
ce04e36f2a55
Doc fixes. Remove overbroad, redundant warnings. Fixup example code.
Raymond Hettinger <python@rcn.com>
parents:
51292
diff
changeset
|
303 >>> # Elementwise multiplication |
|
ce04e36f2a55
Doc fixes. Remove overbroad, redundant warnings. Fixup example code.
Raymond Hettinger <python@rcn.com>
parents:
51292
diff
changeset
|
304 >>> map(mul, [0, 1, 2, 3], [10, 20, 30, 40]) |
|
ce04e36f2a55
Doc fixes. Remove overbroad, redundant warnings. Fixup example code.
Raymond Hettinger <python@rcn.com>
parents:
51292
diff
changeset
|
305 [0, 20, 60, 120] |
|
ce04e36f2a55
Doc fixes. Remove overbroad, redundant warnings. Fixup example code.
Raymond Hettinger <python@rcn.com>
parents:
51292
diff
changeset
|
306 |
|
ce04e36f2a55
Doc fixes. Remove overbroad, redundant warnings. Fixup example code.
Raymond Hettinger <python@rcn.com>
parents:
51292
diff
changeset
|
307 >>> # Dot product |
|
ce04e36f2a55
Doc fixes. Remove overbroad, redundant warnings. Fixup example code.
Raymond Hettinger <python@rcn.com>
parents:
51292
diff
changeset
|
308 >>> sum(map(mul, [0, 1, 2, 3], [10, 20, 30, 40])) |
|
ce04e36f2a55
Doc fixes. Remove overbroad, redundant warnings. Fixup example code.
Raymond Hettinger <python@rcn.com>
parents:
51292
diff
changeset
|
309 200 |
|
50065
ae98681058b2
Merged revisions 67571,67574-67576,67579-67581,67583,67591,67597,67608,67631 via svnmerge from
Georg Brandl <georg@python.org>
parents:
47937
diff
changeset
|
310 |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
311 Many operations have an "in-place" version. The following functions provide a |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
312 more primitive access to in-place operators than the usual syntax does; for |
|
44103
1e266015cf5b
Add more entries to the glossary.
Georg Brandl <georg@python.org>
parents:
43359
diff
changeset
|
313 example, the :term:`statement` ``x += y`` is equivalent to |
|
1e266015cf5b
Add more entries to the glossary.
Georg Brandl <georg@python.org>
parents:
43359
diff
changeset
|
314 ``x = operator.iadd(x, y)``. Another way to put it is to say that |
|
1e266015cf5b
Add more entries to the glossary.
Georg Brandl <georg@python.org>
parents:
43359
diff
changeset
|
315 ``z = operator.iadd(x, y)`` is equivalent to the compound statement |
|
1e266015cf5b
Add more entries to the glossary.
Georg Brandl <georg@python.org>
parents:
43359
diff
changeset
|
316 ``z = x; z += y``. |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
317 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
318 .. function:: iadd(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
319 __iadd__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
320 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
321 ``a = iadd(a, b)`` is equivalent to ``a += b``. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
322 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
323 .. versionadded:: 2.5 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
324 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
325 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
326 .. function:: iand(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
327 __iand__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
328 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
329 ``a = iand(a, b)`` is equivalent to ``a &= b``. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
330 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
331 .. versionadded:: 2.5 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
332 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
333 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
334 .. function:: iconcat(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
335 __iconcat__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
336 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
337 ``a = iconcat(a, b)`` is equivalent to ``a += b`` for *a* and *b* sequences. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
338 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
339 .. versionadded:: 2.5 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
340 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
341 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
342 .. function:: idiv(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
343 __idiv__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
344 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
345 ``a = idiv(a, b)`` is equivalent to ``a /= b`` when ``__future__.division`` is |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
346 not in effect. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
347 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
348 .. versionadded:: 2.5 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
349 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
350 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
351 .. function:: ifloordiv(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
352 __ifloordiv__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
353 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
354 ``a = ifloordiv(a, b)`` is equivalent to ``a //= b``. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
355 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
356 .. versionadded:: 2.5 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
357 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
358 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
359 .. function:: ilshift(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
360 __ilshift__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
361 |
|
59829
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
362 ``a = ilshift(a, b)`` is equivalent to ``a <<= b``. |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
363 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
364 .. versionadded:: 2.5 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
365 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
366 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
367 .. function:: imod(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
368 __imod__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
369 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
370 ``a = imod(a, b)`` is equivalent to ``a %= b``. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
371 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
372 .. versionadded:: 2.5 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
373 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
374 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
375 .. function:: imul(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
376 __imul__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
377 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
378 ``a = imul(a, b)`` is equivalent to ``a *= b``. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
379 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
380 .. versionadded:: 2.5 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
381 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
382 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
383 .. function:: ior(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
384 __ior__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
385 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
386 ``a = ior(a, b)`` is equivalent to ``a |= b``. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
387 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
388 .. versionadded:: 2.5 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
389 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
390 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
391 .. function:: ipow(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
392 __ipow__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
393 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
394 ``a = ipow(a, b)`` is equivalent to ``a **= b``. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
395 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
396 .. versionadded:: 2.5 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
397 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
398 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
399 .. function:: irepeat(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
400 __irepeat__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
401 |
|
51291
7354f1afaecb
Record operator deprecations in docs.
Raymond Hettinger <python@rcn.com>
parents:
50522
diff
changeset
|
402 .. deprecated:: 2.7 |
|
7354f1afaecb
Record operator deprecations in docs.
Raymond Hettinger <python@rcn.com>
parents:
50522
diff
changeset
|
403 Use :func:`__imul__` instead. |
|
51292
7ba41c0917ff
Record operator deprecations in docs.
Raymond Hettinger <python@rcn.com>
parents:
50522
diff
changeset
|
404 |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
405 ``a = irepeat(a, b)`` is equivalent to ``a *= b`` where *a* is a sequence and |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
406 *b* is an integer. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
407 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
408 .. versionadded:: 2.5 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
409 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
410 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
411 .. function:: irshift(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
412 __irshift__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
413 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
414 ``a = irshift(a, b)`` is equivalent to ``a >>= b``. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
415 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
416 .. versionadded:: 2.5 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
417 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
418 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
419 .. function:: isub(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
420 __isub__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
421 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
422 ``a = isub(a, b)`` is equivalent to ``a -= b``. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
423 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
424 .. versionadded:: 2.5 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
425 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
426 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
427 .. function:: itruediv(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
428 __itruediv__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
429 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
430 ``a = itruediv(a, b)`` is equivalent to ``a /= b`` when ``__future__.division`` |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
431 is in effect. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
432 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
433 .. versionadded:: 2.5 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
434 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
435 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
436 .. function:: ixor(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
437 __ixor__(a, b) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
438 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
439 ``a = ixor(a, b)`` is equivalent to ``a ^= b``. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
440 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
441 .. versionadded:: 2.5 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
442 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
443 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
444 The :mod:`operator` module also defines a few predicates to test the type of |
|
51292
7ba41c0917ff
Record operator deprecations in docs.
Raymond Hettinger <python@rcn.com>
parents:
50522
diff
changeset
|
445 objects; however, these are not all reliable. It is preferable to test |
|
7ba41c0917ff
Record operator deprecations in docs.
Raymond Hettinger <python@rcn.com>
parents:
50522
diff
changeset
|
446 abstract base classes instead (see :mod:`collections` and |
|
7ba41c0917ff
Record operator deprecations in docs.
Raymond Hettinger <python@rcn.com>
parents:
50522
diff
changeset
|
447 :mod:`numbers` for details). |
|
43359
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
448 |
|
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
449 .. function:: isCallable(obj) |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
450 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
451 .. deprecated:: 2.0 |
|
51292
7ba41c0917ff
Record operator deprecations in docs.
Raymond Hettinger <python@rcn.com>
parents:
50522
diff
changeset
|
452 Use ``isinstance(x, collections.Callable)`` instead. |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
453 |
|
43359
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
454 Returns true if the object *obj* can be called like a function, otherwise it |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
455 returns false. True is returned for functions, bound and unbound methods, class |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
456 objects, and instance objects which support the :meth:`__call__` method. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
457 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
458 |
|
43359
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
459 .. function:: isMappingType(obj) |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
460 |
|
51291
7354f1afaecb
Record operator deprecations in docs.
Raymond Hettinger <python@rcn.com>
parents:
50522
diff
changeset
|
461 .. deprecated:: 2.7 |
|
7354f1afaecb
Record operator deprecations in docs.
Raymond Hettinger <python@rcn.com>
parents:
50522
diff
changeset
|
462 Use ``isinstance(x, collections.Mapping)`` instead. |
|
51292
7ba41c0917ff
Record operator deprecations in docs.
Raymond Hettinger <python@rcn.com>
parents:
50522
diff
changeset
|
463 |
|
43359
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
464 Returns true if the object *obj* supports the mapping interface. This is true for |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
465 dictionaries and all instance objects defining :meth:`__getitem__`. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
466 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
467 |
|
43359
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
468 .. function:: isNumberType(obj) |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
469 |
|
51291
7354f1afaecb
Record operator deprecations in docs.
Raymond Hettinger <python@rcn.com>
parents:
50522
diff
changeset
|
470 .. deprecated:: 2.7 |
|
7354f1afaecb
Record operator deprecations in docs.
Raymond Hettinger <python@rcn.com>
parents:
50522
diff
changeset
|
471 Use ``isinstance(x, numbers.Number)`` instead. |
|
51292
7ba41c0917ff
Record operator deprecations in docs.
Raymond Hettinger <python@rcn.com>
parents:
50522
diff
changeset
|
472 |
|
43359
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
473 Returns true if the object *obj* represents a number. This is true for all |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
474 numeric types implemented in C. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
475 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
476 |
|
43359
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
477 .. function:: isSequenceType(obj) |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
478 |
|
51291
7354f1afaecb
Record operator deprecations in docs.
Raymond Hettinger <python@rcn.com>
parents:
50522
diff
changeset
|
479 .. deprecated:: 2.7 |
|
7354f1afaecb
Record operator deprecations in docs.
Raymond Hettinger <python@rcn.com>
parents:
50522
diff
changeset
|
480 Use ``isinstance(x, collections.Sequence)`` instead. |
|
51292
7ba41c0917ff
Record operator deprecations in docs.
Raymond Hettinger <python@rcn.com>
parents:
50522
diff
changeset
|
481 |
|
43359
c79a2f0a7034
Replaced variable o with obj in operator.rst because o is easy to
Mark Summerfield <list@qtrac.plus.com>
parents:
42603
diff
changeset
|
482 Returns true if the object *obj* supports the sequence protocol. This returns true |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
483 for all objects which define sequence methods in C, and for all instance objects |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
484 defining :meth:`__getitem__`. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
485 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
486 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
487 The :mod:`operator` module also defines tools for generalized attribute and item |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
488 lookups. These are useful for making fast field extractors as arguments for |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
489 :func:`map`, :func:`sorted`, :meth:`itertools.groupby`, or other functions that |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
490 expect a function argument. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
491 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
492 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
493 .. function:: attrgetter(attr[, args...]) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
494 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
495 Return a callable object that fetches *attr* from its operand. If more than one |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
496 attribute is requested, returns a tuple of attributes. After, |
|
45487
813c146858f7
#1826: allow dotted attribute paths in operator.attrgetter.
Georg Brandl <georg@python.org>
parents:
44103
diff
changeset
|
497 ``f = attrgetter('name')``, the call ``f(b)`` returns ``b.name``. After, |
|
813c146858f7
#1826: allow dotted attribute paths in operator.attrgetter.
Georg Brandl <georg@python.org>
parents:
44103
diff
changeset
|
498 ``f = attrgetter('name', 'date')``, the call ``f(b)`` returns ``(b.name, |
|
64214
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
499 b.date)``. Equivalent to:: |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
500 |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
501 def attrgetter(*items): |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
502 if len(items) == 1: |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
503 attr = items[0] |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
504 def g(obj): |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
505 return resolve_attr(obj, attr) |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
506 else: |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
507 def g(obj): |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
508 return tuple(resolve_att(obj, attr) for attr in items) |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
509 return g |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
510 |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
511 def resolve_attr(obj, attr): |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
512 for name in attr.split("."): |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
513 obj = getattr(obj, name) |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
514 return obj |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
515 |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
516 |
|
45487
813c146858f7
#1826: allow dotted attribute paths in operator.attrgetter.
Georg Brandl <georg@python.org>
parents:
44103
diff
changeset
|
517 The attribute names can also contain dots; after ``f = attrgetter('date.month')``, |
|
813c146858f7
#1826: allow dotted attribute paths in operator.attrgetter.
Georg Brandl <georg@python.org>
parents:
44103
diff
changeset
|
518 the call ``f(b)`` returns ``b.date.month``. |
|
813c146858f7
#1826: allow dotted attribute paths in operator.attrgetter.
Georg Brandl <georg@python.org>
parents:
44103
diff
changeset
|
519 |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
520 .. versionadded:: 2.4 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
521 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
522 .. versionchanged:: 2.5 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
523 Added support for multiple attributes. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
524 |
|
45487
813c146858f7
#1826: allow dotted attribute paths in operator.attrgetter.
Georg Brandl <georg@python.org>
parents:
44103
diff
changeset
|
525 .. versionchanged:: 2.6 |
|
813c146858f7
#1826: allow dotted attribute paths in operator.attrgetter.
Georg Brandl <georg@python.org>
parents:
44103
diff
changeset
|
526 Added support for dotted attributes. |
|
813c146858f7
#1826: allow dotted attribute paths in operator.attrgetter.
Georg Brandl <georg@python.org>
parents:
44103
diff
changeset
|
527 |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
528 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
529 .. function:: itemgetter(item[, args...]) |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
530 |
|
45732
ce5f6fd57913
Improve docs for itemgetter(). Show that it works with slices.
Raymond Hettinger <python@rcn.com>
parents:
45488
diff
changeset
|
531 Return a callable object that fetches *item* from its operand using the |
|
ce5f6fd57913
Improve docs for itemgetter(). Show that it works with slices.
Raymond Hettinger <python@rcn.com>
parents:
45488
diff
changeset
|
532 operand's :meth:`__getitem__` method. If multiple items are specified, |
|
ce5f6fd57913
Improve docs for itemgetter(). Show that it works with slices.
Raymond Hettinger <python@rcn.com>
parents:
45488
diff
changeset
|
533 returns a tuple of lookup values. Equivalent to:: |
|
ce5f6fd57913
Improve docs for itemgetter(). Show that it works with slices.
Raymond Hettinger <python@rcn.com>
parents:
45488
diff
changeset
|
534 |
|
64214
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
535 def itemgetter(*items): |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
536 if len(items) == 1: |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
537 item = items[0] |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
538 def g(obj): |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
539 return obj[item] |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
540 else: |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
541 def g(obj): |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
542 return tuple(obj[item] for item in items) |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
543 return g |
|
50522
ee9ced92843a
Merged revisions 68133-68134,68141-68142,68145-68146,68148-68149,68159-68162,68166,68171-68174,68179,68195-68196,68210,68214-68215,68217-68222 via svnmerge from
Georg Brandl <georg@python.org>
parents:
50065
diff
changeset
|
544 |
|
ee9ced92843a
Merged revisions 68133-68134,68141-68142,68145-68146,68148-68149,68159-68162,68166,68171-68174,68179,68195-68196,68210,68214-68215,68217-68222 via svnmerge from
Georg Brandl <georg@python.org>
parents:
50065
diff
changeset
|
545 The items can be any type accepted by the operand's :meth:`__getitem__` |
|
ee9ced92843a
Merged revisions 68133-68134,68141-68142,68145-68146,68148-68149,68159-68162,68166,68171-68174,68179,68195-68196,68210,68214-68215,68217-68222 via svnmerge from
Georg Brandl <georg@python.org>
parents:
50065
diff
changeset
|
546 method. Dictionaries accept any hashable value. Lists, tuples, and |
|
46012
2e5ab35ccaf1
Test doctests in operator docs.
Georg Brandl <georg@python.org>
parents:
45732
diff
changeset
|
547 strings accept an index or a slice: |
|
45732
ce5f6fd57913
Improve docs for itemgetter(). Show that it works with slices.
Raymond Hettinger <python@rcn.com>
parents:
45488
diff
changeset
|
548 |
|
46012
2e5ab35ccaf1
Test doctests in operator docs.
Georg Brandl <georg@python.org>
parents:
45732
diff
changeset
|
549 >>> itemgetter(1)('ABCDEFG') |
|
2e5ab35ccaf1
Test doctests in operator docs.
Georg Brandl <georg@python.org>
parents:
45732
diff
changeset
|
550 'B' |
|
2e5ab35ccaf1
Test doctests in operator docs.
Georg Brandl <georg@python.org>
parents:
45732
diff
changeset
|
551 >>> itemgetter(1,3,5)('ABCDEFG') |
|
2e5ab35ccaf1
Test doctests in operator docs.
Georg Brandl <georg@python.org>
parents:
45732
diff
changeset
|
552 ('B', 'D', 'F') |
|
2e5ab35ccaf1
Test doctests in operator docs.
Georg Brandl <georg@python.org>
parents:
45732
diff
changeset
|
553 >>> itemgetter(slice(2,None))('ABCDEFG') |
|
2e5ab35ccaf1
Test doctests in operator docs.
Georg Brandl <georg@python.org>
parents:
45732
diff
changeset
|
554 'CDEFG' |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
555 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
556 .. versionadded:: 2.4 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
557 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
558 .. versionchanged:: 2.5 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
559 Added support for multiple item extraction. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
560 |
|
45732
ce5f6fd57913
Improve docs for itemgetter(). Show that it works with slices.
Raymond Hettinger <python@rcn.com>
parents:
45488
diff
changeset
|
561 Example of using :func:`itemgetter` to retrieve specific fields from a |
|
46012
2e5ab35ccaf1
Test doctests in operator docs.
Georg Brandl <georg@python.org>
parents:
45732
diff
changeset
|
562 tuple record: |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
563 |
|
64214
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
564 >>> inventory = [('apple', 3), ('banana', 2), ('pear', 5), ('orange', 1)] |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
565 >>> getcount = itemgetter(1) |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
566 >>> map(getcount, inventory) |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
567 [3, 2, 5, 1] |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
568 >>> sorted(inventory, key=getcount) |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
569 [('orange', 1), ('banana', 2), ('apple', 3), ('pear', 5)] |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
570 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
571 |
|
45488
c126bd9b505b
#1506171: added operator.methodcaller().
Georg Brandl <georg@python.org>
parents:
45487
diff
changeset
|
572 .. function:: methodcaller(name[, args...]) |
|
c126bd9b505b
#1506171: added operator.methodcaller().
Georg Brandl <georg@python.org>
parents:
45487
diff
changeset
|
573 |
|
c126bd9b505b
#1506171: added operator.methodcaller().
Georg Brandl <georg@python.org>
parents:
45487
diff
changeset
|
574 Return a callable object that calls the method *name* on its operand. If |
|
c126bd9b505b
#1506171: added operator.methodcaller().
Georg Brandl <georg@python.org>
parents:
45487
diff
changeset
|
575 additional arguments and/or keyword arguments are given, they will be given |
|
c126bd9b505b
#1506171: added operator.methodcaller().
Georg Brandl <georg@python.org>
parents:
45487
diff
changeset
|
576 to the method as well. After ``f = methodcaller('name')``, the call ``f(b)`` |
|
c126bd9b505b
#1506171: added operator.methodcaller().
Georg Brandl <georg@python.org>
parents:
45487
diff
changeset
|
577 returns ``b.name()``. After ``f = methodcaller('name', 'foo', bar=1)``, the |
|
64214
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
578 call ``f(b)`` returns ``b.name('foo', bar=1)``. Equivalent to:: |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
579 |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
580 def methodcaller(name, *args, **kwargs): |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
581 def caller(obj): |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
582 return getattr(obj, name)(*args, **kwargs) |
|
10df93872ca7
Merged revisions 84242-84244 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
57111
diff
changeset
|
583 return caller |
|
45488
c126bd9b505b
#1506171: added operator.methodcaller().
Georg Brandl <georg@python.org>
parents:
45487
diff
changeset
|
584 |
|
c126bd9b505b
#1506171: added operator.methodcaller().
Georg Brandl <georg@python.org>
parents:
45487
diff
changeset
|
585 .. versionadded:: 2.6 |
|
c126bd9b505b
#1506171: added operator.methodcaller().
Georg Brandl <georg@python.org>
parents:
45487
diff
changeset
|
586 |
|
c126bd9b505b
#1506171: added operator.methodcaller().
Georg Brandl <georg@python.org>
parents:
45487
diff
changeset
|
587 |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
588 .. _operator-map: |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
589 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
590 Mapping Operators to Functions |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
591 ------------------------------ |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
592 |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
593 This table shows how abstract operations correspond to operator symbols in the |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
594 Python syntax and the functions in the :mod:`operator` module. |
|
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
595 |
|
59829
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
596 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
597 | Operation | Syntax | Function | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
598 +=======================+=========================+=======================================+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
599 | Addition | ``a + b`` | ``add(a, b)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
600 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
601 | Concatenation | ``seq1 + seq2`` | ``concat(seq1, seq2)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
602 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
603 | Containment Test | ``obj in seq`` | ``contains(seq, obj)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
604 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
605 | Division | ``a / b`` | ``div(a, b)`` (without | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
606 | | | ``__future__.division``) | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
607 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
608 | Division | ``a / b`` | ``truediv(a, b)`` (with | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
609 | | | ``__future__.division``) | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
610 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
611 | Division | ``a // b`` | ``floordiv(a, b)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
612 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
613 | Bitwise And | ``a & b`` | ``and_(a, b)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
614 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
615 | Bitwise Exclusive Or | ``a ^ b`` | ``xor(a, b)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
616 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
617 | Bitwise Inversion | ``~ a`` | ``invert(a)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
618 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
619 | Bitwise Or | ``a | b`` | ``or_(a, b)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
620 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
621 | Exponentiation | ``a ** b`` | ``pow(a, b)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
622 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
623 | Identity | ``a is b`` | ``is_(a, b)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
624 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
625 | Identity | ``a is not b`` | ``is_not(a, b)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
626 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
627 | Indexed Assignment | ``obj[k] = v`` | ``setitem(obj, k, v)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
628 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
629 | Indexed Deletion | ``del obj[k]`` | ``delitem(obj, k)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
630 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
631 | Indexing | ``obj[k]`` | ``getitem(obj, k)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
632 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
633 | Left Shift | ``a << b`` | ``lshift(a, b)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
634 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
635 | Modulo | ``a % b`` | ``mod(a, b)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
636 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
637 | Multiplication | ``a * b`` | ``mul(a, b)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
638 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
639 | Negation (Arithmetic) | ``- a`` | ``neg(a)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
640 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
641 | Negation (Logical) | ``not a`` | ``not_(a)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
642 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
643 | Positive | ``+ a`` | ``pos(a)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
644 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
645 | Right Shift | ``a >> b`` | ``rshift(a, b)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
646 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
647 | Sequence Repetition | ``seq * i`` | ``repeat(seq, i)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
648 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
649 | Slice Assignment | ``seq[i:j] = values`` | ``setitem(seq, slice(i, j), values)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
650 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
651 | Slice Deletion | ``del seq[i:j]`` | ``delitem(seq, slice(i, j))`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
652 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
653 | Slicing | ``seq[i:j]`` | ``getitem(seq, slice(i, j))`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
654 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
655 | String Formatting | ``s % obj`` | ``mod(s, obj)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
656 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
657 | Subtraction | ``a - b`` | ``sub(a, b)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
658 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
659 | Truth Test | ``obj`` | ``truth(obj)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
660 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
661 | Ordering | ``a < b`` | ``lt(a, b)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
662 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
663 | Ordering | ``a <= b`` | ``le(a, b)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
664 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
665 | Equality | ``a == b`` | ``eq(a, b)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
666 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
667 | Difference | ``a != b`` | ``ne(a, b)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
668 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
669 | Ordering | ``a >= b`` | ``ge(a, b)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
670 +-----------------------+-------------------------+---------------------------------------+ |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
671 | Ordering | ``a > b`` | ``gt(a, b)`` | |
|
edc92bce4d6e
Merged revisions 75952-75953,75955,76105,76143,76223,76259,76326,76376-76377 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51316
diff
changeset
|
672 +-----------------------+-------------------------+---------------------------------------+ |
|
42603
c62f6669ae22
Move the 2.6 reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
673 |
