annotate Doc/lib/liboperator.tex @ 38664:7619216bbc19 2.4

Bug #1502728: Correctly link against librt library on HP-UX. (backport from rev. 46743)
author Georg Brandl <georg@python.org>
date Thu, 08 Jun 2006 12:54:16 +0000
parents c2a9c3a18477
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8918
acfffe14628e New section header style.
Fred Drake <fdrake@acm.org>
parents: 8716
diff changeset
1 \section{\module{operator} ---
acfffe14628e New section header style.
Fred Drake <fdrake@acm.org>
parents: 8716
diff changeset
2 Standard operators as functions.}
8716
760dcf197048 Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents: 8418
diff changeset
3 \declaremodule{builtin}{operator}
8918
acfffe14628e New section header style.
Fred Drake <fdrake@acm.org>
parents: 8716
diff changeset
4 \sectionauthor{Skip Montanaro}{skip@automatrix.com}
8716
760dcf197048 Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents: 8418
diff changeset
5
760dcf197048 Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents: 8418
diff changeset
6 \modulesynopsis{All Python's standard operators as built-in functions.}
760dcf197048 Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents: 8418
diff changeset
7
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
8
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
9 The \module{operator} module exports a set of functions implemented in C
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 corresponding to the intrinsic operators of Python. For example,
6955
38493b9376ea Remove unneeded "{}" that confused makeinfo.
Fred Drake <fdrake@acm.org>
parents: 6876
diff changeset
11 \code{operator.add(x, y)} is equivalent to the expression \code{x+y}. The
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 function names are those used for special class methods; variants without
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
13 leading and trailing \samp{__} are also provided for convenience.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
14
19132
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
15 The functions fall into categories that perform object comparisons,
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
16 logical operations, mathematical operations, sequence operations, and
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
17 abstract type tests.
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
18
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
19 The object comparison functions are useful for all objects, and are
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
20 named after the rich comparison operators they support:
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
21
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
22 \begin{funcdesc}{lt}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
23 \funcline{le}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
24 \funcline{eq}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
25 \funcline{ne}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
26 \funcline{ge}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
27 \funcline{gt}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
28 \funcline{__lt__}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
29 \funcline{__le__}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
30 \funcline{__eq__}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
31 \funcline{__ne__}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
32 \funcline{__ge__}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
33 \funcline{__gt__}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
34 Perform ``rich comparisons'' between \var{a} and \var{b}. Specifically,
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
35 \code{lt(\var{a}, \var{b})} is equivalent to \code{\var{a} < \var{b}},
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
36 \code{le(\var{a}, \var{b})} is equivalent to \code{\var{a} <= \var{b}},
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
37 \code{eq(\var{a}, \var{b})} is equivalent to \code{\var{a} == \var{b}},
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
38 \code{ne(\var{a}, \var{b})} is equivalent to \code{\var{a} != \var{b}},
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
39 \code{gt(\var{a}, \var{b})} is equivalent to \code{\var{a} > \var{b}}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
40 and
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
41 \code{ge(\var{a}, \var{b})} is equivalent to \code{\var{a} >= \var{b}}.
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
42 Note that unlike the built-in \function{cmp()}, these functions can
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
43 return any value, which may or may not be interpretable as a Boolean
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
44 value. See the \citetitle[../ref/ref.html]{Python Reference Manual}
34296
67f2190e1f6d SF Patch #1093896: miscellaneous doc typos
Raymond Hettinger <python@rcn.com>
parents: 31212
diff changeset
45 for more information about rich comparisons.
19132
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
46 \versionadded{2.2}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
47 \end{funcdesc}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
48
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
49
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
50 The logical operations are also generally applicable to all objects,
28003
16b25032217f Fill in missing table entries.
Raymond Hettinger <python@rcn.com>
parents: 27290
diff changeset
51 and support truth tests, identity tests, and boolean operations:
19132
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
52
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
53 \begin{funcdesc}{not_}{o}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
54 \funcline{__not__}{o}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
55 Return the outcome of \keyword{not} \var{o}. (Note that there is no
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
56 \method{__not__()} method for object instances; only the interpreter
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
57 core defines this operation. The result is affected by the
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
58 \method{__nonzero__()} and \method{__len__()} methods.)
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
59 \end{funcdesc}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
60
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
61 \begin{funcdesc}{truth}{o}
27219
2ed518ab2fd2 Minor correction and clarification.
Fred Drake <fdrake@acm.org>
parents: 24904
diff changeset
62 Return \constant{True} if \var{o} is true, and \constant{False}
27223
201cdeb305f6 Try to make a sentance more readable.
Neal Norwitz <nnorwitz@gmail.com>
parents: 27219
diff changeset
63 otherwise. This is equivalent to using the \class{bool}
27219
2ed518ab2fd2 Minor correction and clarification.
Fred Drake <fdrake@acm.org>
parents: 24904
diff changeset
64 constructor.
19132
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
65 \end{funcdesc}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
66
27290
e83a42a90df1 SF patch #670423: Add missing identity tests to operator.c
Raymond Hettinger <python@rcn.com>
parents: 27223
diff changeset
67 \begin{funcdesc}{is_}{a, b}
e83a42a90df1 SF patch #670423: Add missing identity tests to operator.c
Raymond Hettinger <python@rcn.com>
parents: 27223
diff changeset
68 Return \code{\var{a} is \var{b}}. Tests object identity.
30840
fef6fdec5292 SF patch #834444: add versionadd to new functions
Raymond Hettinger <python@rcn.com>
parents: 28003
diff changeset
69 \versionadded{2.3}
27290
e83a42a90df1 SF patch #670423: Add missing identity tests to operator.c
Raymond Hettinger <python@rcn.com>
parents: 27223
diff changeset
70 \end{funcdesc}
e83a42a90df1 SF patch #670423: Add missing identity tests to operator.c
Raymond Hettinger <python@rcn.com>
parents: 27223
diff changeset
71
e83a42a90df1 SF patch #670423: Add missing identity tests to operator.c
Raymond Hettinger <python@rcn.com>
parents: 27223
diff changeset
72 \begin{funcdesc}{is_not}{a, b}
e83a42a90df1 SF patch #670423: Add missing identity tests to operator.c
Raymond Hettinger <python@rcn.com>
parents: 27223
diff changeset
73 Return \code{\var{a} is not \var{b}}. Tests object identity.
30840
fef6fdec5292 SF patch #834444: add versionadd to new functions
Raymond Hettinger <python@rcn.com>
parents: 28003
diff changeset
74 \versionadded{2.3}
27290
e83a42a90df1 SF patch #670423: Add missing identity tests to operator.c
Raymond Hettinger <python@rcn.com>
parents: 27223
diff changeset
75 \end{funcdesc}
e83a42a90df1 SF patch #670423: Add missing identity tests to operator.c
Raymond Hettinger <python@rcn.com>
parents: 27223
diff changeset
76
19132
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
77
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
78 The mathematical and bitwise operations are the most numerous:
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
79
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
80 \begin{funcdesc}{abs}{o}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
81 \funcline{__abs__}{o}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
82 Return the absolute value of \var{o}.
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
83 \end{funcdesc}
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
84
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
85 \begin{funcdesc}{add}{a, b}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
86 \funcline{__add__}{a, b}
6876
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
87 Return \var{a} \code{+} \var{b}, for \var{a} and \var{b} numbers.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
88 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
89
19132
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
90 \begin{funcdesc}{and_}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
91 \funcline{__and__}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
92 Return the bitwise and of \var{a} and \var{b}.
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
93 \end{funcdesc}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
94
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
95 \begin{funcdesc}{div}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
96 \funcline{__div__}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
97 Return \var{a} \code{/} \var{b} when \code{__future__.division} is not
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
98 in effect. This is also known as ``classic'' division.
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
99 \end{funcdesc}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
100
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
101 \begin{funcdesc}{floordiv}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
102 \funcline{__floordiv__}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
103 Return \var{a} \code{//} \var{b}.
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
104 \versionadded{2.2}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
105 \end{funcdesc}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
106
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
107 \begin{funcdesc}{inv}{o}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
108 \funcline{invert}{o}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
109 \funcline{__inv__}{o}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
110 \funcline{__invert__}{o}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
111 Return the bitwise inverse of the number \var{o}. This is equivalent
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
112 to \code{\textasciitilde}\var{o}. The names \function{invert()} and
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
113 \function{__invert__()} were added in Python 2.0.
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
114 \end{funcdesc}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
115
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
116 \begin{funcdesc}{lshift}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
117 \funcline{__lshift__}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
118 Return \var{a} shifted left by \var{b}.
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
119 \end{funcdesc}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
120
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
121 \begin{funcdesc}{mod}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
122 \funcline{__mod__}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
123 Return \var{a} \code{\%} \var{b}.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
124 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
125
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
126 \begin{funcdesc}{mul}{a, b}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
127 \funcline{__mul__}{a, b}
6876
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
128 Return \var{a} \code{*} \var{b}, for \var{a} and \var{b} numbers.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
129 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
130
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
131 \begin{funcdesc}{neg}{o}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
132 \funcline{__neg__}{o}
6876
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
133 Return \var{o} negated.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
134 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
135
19132
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
136 \begin{funcdesc}{or_}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
137 \funcline{__or__}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
138 Return the bitwise or of \var{a} and \var{b}.
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
139 \end{funcdesc}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
140
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
141 \begin{funcdesc}{pos}{o}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
142 \funcline{__pos__}{o}
6876
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
143 Return \var{o} positive.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
144 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
145
24887
d797cfa8ca0d Added __pow__(a,b) to the operator module. Completes the pattern of
Raymond Hettinger <python@rcn.com>
parents: 20580
diff changeset
146 \begin{funcdesc}{pow}{a, b}
d797cfa8ca0d Added __pow__(a,b) to the operator module. Completes the pattern of
Raymond Hettinger <python@rcn.com>
parents: 20580
diff changeset
147 \funcline{__pow__}{a, b}
d797cfa8ca0d Added __pow__(a,b) to the operator module. Completes the pattern of
Raymond Hettinger <python@rcn.com>
parents: 20580
diff changeset
148 Return \var{a} \code{**} \var{b}, for \var{a} and \var{b} numbers.
24904
641786bea13e Add versionadded for operator.pow
Neal Norwitz <nnorwitz@gmail.com>
parents: 24887
diff changeset
149 \versionadded{2.3}
24887
d797cfa8ca0d Added __pow__(a,b) to the operator module. Completes the pattern of
Raymond Hettinger <python@rcn.com>
parents: 20580
diff changeset
150 \end{funcdesc}
d797cfa8ca0d Added __pow__(a,b) to the operator module. Completes the pattern of
Raymond Hettinger <python@rcn.com>
parents: 20580
diff changeset
151
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
152 \begin{funcdesc}{rshift}{a, b}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
153 \funcline{__rshift__}{a, b}
6876
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
154 Return \var{a} shifted right by \var{b}.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
155 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
156
19132
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
157 \begin{funcdesc}{sub}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
158 \funcline{__sub__}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
159 Return \var{a} \code{-} \var{b}.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
160 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
161
19132
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
162 \begin{funcdesc}{truediv}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
163 \funcline{__truediv__}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
164 Return \var{a} \code{/} \var{b} when \code{__future__.division} is in
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
165 effect. This is also known as division.
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
166 \versionadded{2.2}
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
167 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
168
8418
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
169 \begin{funcdesc}{xor}{a, b}
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
170 \funcline{__xor__}{a, b}
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
171 Return the bitwise exclusive or of \var{a} and \var{b}.
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
172 \end{funcdesc}
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
173
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
174
19132
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
175 Operations which work with sequences include:
8418
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
176
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
177 \begin{funcdesc}{concat}{a, b}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
178 \funcline{__concat__}{a, b}
6876
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
179 Return \var{a} \code{+} \var{b} for \var{a} and \var{b} sequences.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
180 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
181
8418
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
182 \begin{funcdesc}{contains}{a, b}
14655
0228914e0c5f Added documentation for new functions.
Fred Drake <fdrake@acm.org>
parents: 10991
diff changeset
183 \funcline{__contains__}{a, b}
8418
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
184 Return the outcome of the test \var{b} \code{in} \var{a}.
14655
0228914e0c5f Added documentation for new functions.
Fred Drake <fdrake@acm.org>
parents: 10991
diff changeset
185 Note the reversed operands. The name \function{__contains__()} was
0228914e0c5f Added documentation for new functions.
Fred Drake <fdrake@acm.org>
parents: 10991
diff changeset
186 added in Python 2.0.
0228914e0c5f Added documentation for new functions.
Fred Drake <fdrake@acm.org>
parents: 10991
diff changeset
187 \end{funcdesc}
0228914e0c5f Added documentation for new functions.
Fred Drake <fdrake@acm.org>
parents: 10991
diff changeset
188
8418
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
189 \begin{funcdesc}{countOf}{a, b}
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
190 Return the number of occurrences of \var{b} in \var{a}.
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
191 \end{funcdesc}
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
192
19132
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
193 \begin{funcdesc}{delitem}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
194 \funcline{__delitem__}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
195 Remove the value of \var{a} at index \var{b}.
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
196 \end{funcdesc}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
197
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
198 \begin{funcdesc}{delslice}{a, b, c}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
199 \funcline{__delslice__}{a, b, c}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
200 Delete the slice of \var{a} from index \var{b} to index \var{c}\code{-1}.
8418
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
201 \end{funcdesc}
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
202
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
203 \begin{funcdesc}{getitem}{a, b}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
204 \funcline{__getitem__}{a, b}
6876
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
205 Return the value of \var{a} at index \var{b}.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
206 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
207
19132
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
208 \begin{funcdesc}{getslice}{a, b, c}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
209 \funcline{__getslice__}{a, b, c}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
210 Return the slice of \var{a} from index \var{b} to index \var{c}\code{-1}.
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
211 \end{funcdesc}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
212
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
213 \begin{funcdesc}{indexOf}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
214 Return the index of the first of occurrence of \var{b} in \var{a}.
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
215 \end{funcdesc}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
216
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
217 \begin{funcdesc}{repeat}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
218 \funcline{__repeat__}{a, b}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
219 Return \var{a} \code{*} \var{b} where \var{a} is a sequence and
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
220 \var{b} is an integer.
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
221 \end{funcdesc}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
222
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
223 \begin{funcdesc}{sequenceIncludes}{\unspecified}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
224 \deprecated{2.0}{Use \function{contains()} instead.}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
225 Alias for \function{contains()}.
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
226 \end{funcdesc}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
227
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
228 \begin{funcdesc}{setitem}{a, b, c}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
229 \funcline{__setitem__}{a, b, c}
6876
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
230 Set the value of \var{a} at index \var{b} to \var{c}.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
231 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
232
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
233 \begin{funcdesc}{setslice}{a, b, c, v}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
234 \funcline{__setslice__}{a, b, c, v}
6876
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
235 Set the slice of \var{a} from index \var{b} to index \var{c}\code{-1} to the
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
236 sequence \var{v}.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
237 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
238
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
239
19132
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
240 The \module{operator} module also defines a few predicates to test the
20580
376ee174ecd0 Use the \note and \warning macros where appropriate.
Fred Drake <fdrake@acm.org>
parents: 19132
diff changeset
241 type of objects. \note{Be careful not to misinterpret the
14965
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
242 results of these functions; only \function{isCallable()} has any
20580
376ee174ecd0 Use the \note and \warning macros where appropriate.
Fred Drake <fdrake@acm.org>
parents: 19132
diff changeset
243 measure of reliability with instance objects. For example:}
14965
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
244
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
245 \begin{verbatim}
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
246 >>> class C:
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
247 ... pass
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
248 ...
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
249 >>> import operator
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
250 >>> o = C()
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
251 >>> operator.isMappingType(o)
31029
ce07118ee5d2 Patch #849350: Update to document bool return values. Backported to 2.3.
Martin v. Löwis <martin@v.loewis.de>
parents: 30840
diff changeset
252 True
14965
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
253 \end{verbatim}
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
254
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
255 \begin{funcdesc}{isCallable}{o}
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
256 \deprecated{2.0}{Use the \function{callable()} built-in function instead.}
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
257 Returns true if the object \var{o} can be called like a function,
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
258 otherwise it returns false. True is returned for functions, bound and
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
259 unbound methods, class objects, and instance objects which support the
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
260 \method{__call__()} method.
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
261 \end{funcdesc}
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
262
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
263 \begin{funcdesc}{isMappingType}{o}
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
264 Returns true if the object \var{o} supports the mapping interface.
34876
c2a9c3a18477 SF bug #1178269 Clarify when isMappingType/isSequenceType is True.
Raymond Hettinger <python@rcn.com>
parents: 34874
diff changeset
265 This is true for dictionaries and all instance objects defining
c2a9c3a18477 SF bug #1178269 Clarify when isMappingType/isSequenceType is True.
Raymond Hettinger <python@rcn.com>
parents: 34874
diff changeset
266 \method{__getitem__}.
20580
376ee174ecd0 Use the \note and \warning macros where appropriate.
Fred Drake <fdrake@acm.org>
parents: 19132
diff changeset
267 \warning{There is no reliable way to test if an instance
14965
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
268 supports the complete mapping protocol since the interface itself is
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
269 ill-defined. This makes this test less useful than it otherwise might
20580
376ee174ecd0 Use the \note and \warning macros where appropriate.
Fred Drake <fdrake@acm.org>
parents: 19132
diff changeset
270 be.}
14965
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
271 \end{funcdesc}
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
272
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
273 \begin{funcdesc}{isNumberType}{o}
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
274 Returns true if the object \var{o} represents a number. This is true
34876
c2a9c3a18477 SF bug #1178269 Clarify when isMappingType/isSequenceType is True.
Raymond Hettinger <python@rcn.com>
parents: 34874
diff changeset
275 for all numeric types implemented in C.
20580
376ee174ecd0 Use the \note and \warning macros where appropriate.
Fred Drake <fdrake@acm.org>
parents: 19132
diff changeset
276 \warning{There is no reliable way to test if an instance
14965
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
277 supports the complete numeric interface since the interface itself is
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
278 ill-defined. This makes this test less useful than it otherwise might
20580
376ee174ecd0 Use the \note and \warning macros where appropriate.
Fred Drake <fdrake@acm.org>
parents: 19132
diff changeset
279 be.}
14965
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
280 \end{funcdesc}
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
281
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
282 \begin{funcdesc}{isSequenceType}{o}
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
283 Returns true if the object \var{o} supports the sequence protocol.
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
284 This returns true for all objects which define sequence methods in C,
34876
c2a9c3a18477 SF bug #1178269 Clarify when isMappingType/isSequenceType is True.
Raymond Hettinger <python@rcn.com>
parents: 34874
diff changeset
285 and for all instance objects defining \method{__getitem__}.
c2a9c3a18477 SF bug #1178269 Clarify when isMappingType/isSequenceType is True.
Raymond Hettinger <python@rcn.com>
parents: 34874
diff changeset
286 \warning{There is no reliable
14965
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
287 way to test if an instance supports the complete sequence interface
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
288 since the interface itself is ill-defined. This makes this test less
20580
376ee174ecd0 Use the \note and \warning macros where appropriate.
Fred Drake <fdrake@acm.org>
parents: 19132
diff changeset
289 useful than it otherwise might be.}
14965
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
290 \end{funcdesc}
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
291
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
292
6876
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
293 Example: Build a dictionary that maps the ordinals from \code{0} to
34874
5a522225c4db SF bug #1178255: 256 should read 255 in operator module docs
Raymond Hettinger <python@rcn.com>
parents: 34296
diff changeset
294 \code{255} to their character equivalents.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
295
7277
bf4e790bd61a Remove all \bcode / \ecode cruft; this is no longer needed. See previous
Fred Drake <fdrake@acm.org>
parents: 6955
diff changeset
296 \begin{verbatim}
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
297 >>> import operator
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
298 >>> d = {}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
299 >>> keys = range(256)
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
300 >>> vals = map(chr, keys)
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
301 >>> map(operator.setitem, [d]*len(keys), keys, vals)
7277
bf4e790bd61a Remove all \bcode / \ecode cruft; this is no longer needed. See previous
Fred Drake <fdrake@acm.org>
parents: 6955
diff changeset
302 \end{verbatim}
15291
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
303
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
304
31052
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
305 The \module{operator} module also defines tools for generalized attribute
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
306 and item lookups. These are useful for making fast field extractors
31212
5b035e6e44dc Guido grants a Christmas wish:
Raymond Hettinger <python@rcn.com>
parents: 31052
diff changeset
307 as arguments for \function{map()}, \function{sorted()},
31052
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
308 \method{itertools.groupby()}, or other functions that expect a
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
309 function argument.
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
310
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
311 \begin{funcdesc}{attrgetter}{attr}
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
312 Return a callable object that fetches \var{attr} from its operand.
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
313 After, \samp{f=attrgetter('name')}, the call \samp{f(b)} returns
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
314 \samp{b.name}.
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
315 \versionadded{2.4}
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
316 \end{funcdesc}
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
317
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
318 \begin{funcdesc}{itemgetter}{item}
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
319 Return a callable object that fetches \var{item} from its operand.
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
320 After, \samp{f=itemgetter(2)}, the call \samp{f(b)} returns
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
321 \samp{b[2]}.
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
322 \versionadded{2.4}
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
323 \end{funcdesc}
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
324
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
325 Examples:
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
326
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
327 \begin{verbatim}
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
328 >>> from operator import *
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
329 >>> inventory = [('apple', 3), ('banana', 2), ('pear', 5), ('orange', 1)]
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
330 >>> getcount = itemgetter(1)
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
331 >>> map(getcount, inventory)
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
332 [3, 2, 5, 1]
31212
5b035e6e44dc Guido grants a Christmas wish:
Raymond Hettinger <python@rcn.com>
parents: 31052
diff changeset
333 >>> sorted(inventory, key=getcount)
31052
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
334 [('orange', 1), ('banana', 2), ('apple', 3), ('pear', 5)]
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
335 \end{verbatim}
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
336
456e274f8602 As discussed on python-dev, added two extractor functions to the
Raymond Hettinger <python@rcn.com>
parents: 31029
diff changeset
337
15291
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
338 \subsection{Mapping Operators to Functions \label{operator-map}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
339
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
340 This table shows how abstract operations correspond to operator
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
341 symbols in the Python syntax and the functions in the
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
342 \refmodule{operator} module.
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
343
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
344
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
345 \begin{tableiii}{l|c|l}{textrm}{Operation}{Syntax}{Function}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
346 \lineiii{Addition}{\code{\var{a} + \var{b}}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
347 {\code{add(\var{a}, \var{b})}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
348 \lineiii{Concatenation}{\code{\var{seq1} + \var{seq2}}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
349 {\code{concat(\var{seq1}, \var{seq2})}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
350 \lineiii{Containment Test}{\code{\var{o} in \var{seq}}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
351 {\code{contains(\var{seq}, \var{o})}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
352 \lineiii{Division}{\code{\var{a} / \var{b}}}
19132
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
353 {\code{div(\var{a}, \var{b}) \#} without \code{__future__.division}}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
354 \lineiii{Division}{\code{\var{a} / \var{b}}}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
355 {\code{truediv(\var{a}, \var{b}) \#} with \code{__future__.division}}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
356 \lineiii{Division}{\code{\var{a} // \var{b}}}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
357 {\code{floordiv(\var{a}, \var{b})}}
15291
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
358 \lineiii{Bitwise And}{\code{\var{a} \&\ \var{b}}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
359 {\code{and_(\var{a}, \var{b})}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
360 \lineiii{Bitwise Exclusive Or}{\code{\var{a} \^\ \var{b}}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
361 {\code{xor(\var{a}, \var{b})}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
362 \lineiii{Bitwise Inversion}{\code{\~{} \var{a}}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
363 {\code{invert(\var{a})}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
364 \lineiii{Bitwise Or}{\code{\var{a} | \var{b}}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
365 {\code{or_(\var{a}, \var{b})}}
24887
d797cfa8ca0d Added __pow__(a,b) to the operator module. Completes the pattern of
Raymond Hettinger <python@rcn.com>
parents: 20580
diff changeset
366 \lineiii{Exponentiation}{\code{\var{a} ** \var{b}}}
d797cfa8ca0d Added __pow__(a,b) to the operator module. Completes the pattern of
Raymond Hettinger <python@rcn.com>
parents: 20580
diff changeset
367 {\code{pow(\var{a}, \var{b})}}
28003
16b25032217f Fill in missing table entries.
Raymond Hettinger <python@rcn.com>
parents: 27290
diff changeset
368 \lineiii{Identity}{\code{\var{a} is \var{b}}}
16b25032217f Fill in missing table entries.
Raymond Hettinger <python@rcn.com>
parents: 27290
diff changeset
369 {\code{is_(\var{a}, \var{b})}}
16b25032217f Fill in missing table entries.
Raymond Hettinger <python@rcn.com>
parents: 27290
diff changeset
370 \lineiii{Identity}{\code{\var{a} is not \var{b}}}
16b25032217f Fill in missing table entries.
Raymond Hettinger <python@rcn.com>
parents: 27290
diff changeset
371 {\code{is_not(\var{a}, \var{b})}}
15291
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
372 \lineiii{Indexed Assignment}{\code{\var{o}[\var{k}] = \var{v}}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
373 {\code{setitem(\var{o}, \var{k}, \var{v})}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
374 \lineiii{Indexed Deletion}{\code{del \var{o}[\var{k}]}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
375 {\code{delitem(\var{o}, \var{k})}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
376 \lineiii{Indexing}{\code{\var{o}[\var{k}]}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
377 {\code{getitem(\var{o}, \var{k})}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
378 \lineiii{Left Shift}{\code{\var{a} <\code{<} \var{b}}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
379 {\code{lshift(\var{a}, \var{b})}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
380 \lineiii{Modulo}{\code{\var{a} \%\ \var{b}}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
381 {\code{mod(\var{a}, \var{b})}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
382 \lineiii{Multiplication}{\code{\var{a} * \var{b}}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
383 {\code{mul(\var{a}, \var{b})}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
384 \lineiii{Negation (Arithmetic)}{\code{- \var{a}}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
385 {\code{neg(\var{a})}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
386 \lineiii{Negation (Logical)}{\code{not \var{a}}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
387 {\code{not_(\var{a})}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
388 \lineiii{Right Shift}{\code{\var{a} >\code{>} \var{b}}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
389 {\code{rshift(\var{a}, \var{b})}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
390 \lineiii{Sequence Repitition}{\code{\var{seq} * \var{i}}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
391 {\code{repeat(\var{seq}, \var{i})}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
392 \lineiii{Slice Assignment}{\code{\var{seq}[\var{i}:\var{j}]} = \var{values}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
393 {\code{setslice(\var{seq}, \var{i}, \var{j}, \var{values})}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
394 \lineiii{Slice Deletion}{\code{del \var{seq}[\var{i}:\var{j}]}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
395 {\code{delslice(\var{seq}, \var{i}, \var{j})}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
396 \lineiii{Slicing}{\code{\var{seq}[\var{i}:\var{j}]}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
397 {\code{getslice(\var{seq}, \var{i}, \var{j})}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
398 \lineiii{String Formatting}{\code{\var{s} \%\ \var{o}}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
399 {\code{mod(\var{s}, \var{o})}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
400 \lineiii{Subtraction}{\code{\var{a} - \var{b}}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
401 {\code{sub(\var{a}, \var{b})}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
402 \lineiii{Truth Test}{\code{\var{o}}}
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
403 {\code{truth(\var{o})}}
19132
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
404 \lineiii{Ordering}{\code{\var{a} < \var{b}}}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
405 {\code{lt(\var{a}, \var{b})}}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
406 \lineiii{Ordering}{\code{\var{a} <= \var{b}}}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
407 {\code{le(\var{a}, \var{b})}}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
408 \lineiii{Equality}{\code{\var{a} == \var{b}}}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
409 {\code{eq(\var{a}, \var{b})}}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
410 \lineiii{Difference}{\code{\var{a} != \var{b}}}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
411 {\code{ne(\var{a}, \var{b})}}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
412 \lineiii{Ordering}{\code{\var{a} >= \var{b}}}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
413 {\code{ge(\var{a}, \var{b})}}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
414 \lineiii{Ordering}{\code{\var{a} > \var{b}}}
40a17d9500a8 Added documentation for the new rich comparison support.
Fred Drake <fdrake@acm.org>
parents: 15578
diff changeset
415 {\code{gt(\var{a}, \var{b})}}
15291
1f9d5eb84b0b Added missing entry for invert() function.
Fred Drake <fdrake@acm.org>
parents: 15061
diff changeset
416 \end{tableiii}