annotate Doc/lib/liboperator.tex @ 14984:ece6c19edcc1 legacy-trunk

Remove some debugging prints.
author Greg Ward <gward@python.net>
date Tue, 03 Oct 2000 03:32:37 +0000
parents 1aa37008fd2c
children 103612516aa8
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
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
15 The \module{operator} module defines the following functions:
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
16
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
17 \begin{funcdesc}{add}{a, b}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
18 \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
19 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
20 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
21
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
22 \begin{funcdesc}{sub}{a, b}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
23 \funcline{__sub__}{a, b}
6876
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
24 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
25 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
26
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
27 \begin{funcdesc}{mul}{a, b}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
28 \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
29 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
30 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
31
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
32 \begin{funcdesc}{div}{a, b}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
33 \funcline{__div__}{a, b}
6876
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
34 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
35 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
36
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
37 \begin{funcdesc}{mod}{a, b}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
38 \funcline{__mod__}{a, b}
6876
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
39 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
40 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
41
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 \begin{funcdesc}{neg}{o}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
43 \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
44 Return \var{o} negated.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
46
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 \begin{funcdesc}{pos}{o}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
48 \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
49 Return \var{o} positive.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
51
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 \begin{funcdesc}{abs}{o}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
53 \funcline{__abs__}{o}
6876
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
54 Return the absolute value of \var{o}.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
55 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
56
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 \begin{funcdesc}{inv}{o}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
58 \funcline{__inv__}{o}
14655
0228914e0c5f Added documentation for new functions.
Fred Drake <fdrake@acm.org>
parents: 10991
diff changeset
59 \funcline{__invert__}{o}
0228914e0c5f Added documentation for new functions.
Fred Drake <fdrake@acm.org>
parents: 10991
diff changeset
60 Return the inverse of \var{o}. The names \function{invert()} and
0228914e0c5f Added documentation for new functions.
Fred Drake <fdrake@acm.org>
parents: 10991
diff changeset
61 \function{__invert__()} were added in Python 2.0.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
62 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
63
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
64 \begin{funcdesc}{lshift}{a, b}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
65 \funcline{__lshift__}{a, b}
6876
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
66 Return \var{a} shifted left by \var{b}.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
67 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
68
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
69 \begin{funcdesc}{rshift}{a, b}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
70 \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
71 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
72 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
73
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
74 \begin{funcdesc}{and_}{a, b}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
75 \funcline{__and__}{a, b}
6876
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
76 Return the bitwise and of \var{a} and \var{b}.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
77 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
78
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
79 \begin{funcdesc}{or_}{a, b}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
80 \funcline{__or__}{a, b}
6876
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
81 Return the bitwise or of \var{a} and \var{b}.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
82 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
83
8418
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
84 \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
85 \funcline{__xor__}{a, b}
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
86 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
87 \end{funcdesc}
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
88
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
89 \begin{funcdesc}{not_}{o}
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
90 \funcline{__not__}{o}
10991
46a56177322e Added note to __not__() description that this operation is defined
Fred Drake <fdrake@acm.org>
parents: 8918
diff changeset
91 Return the outcome of \keyword{not} \var{o}. (Note that there is no
46a56177322e Added note to __not__() description that this operation is defined
Fred Drake <fdrake@acm.org>
parents: 8918
diff changeset
92 \method{__not__()} discipline for object instances; only the
46a56177322e Added note to __not__() description that this operation is defined
Fred Drake <fdrake@acm.org>
parents: 8918
diff changeset
93 interpreter core defines this operation.)
8418
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
94 \end{funcdesc}
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
95
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
96 \begin{funcdesc}{truth}{o}
8918
acfffe14628e New section header style.
Fred Drake <fdrake@acm.org>
parents: 8716
diff changeset
97 Return \code{1} if \var{o} is true, and 0 otherwise.
8418
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
98 \end{funcdesc}
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
99
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
100 \begin{funcdesc}{concat}{a, b}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
101 \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
102 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
103 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
104
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
105 \begin{funcdesc}{repeat}{a, b}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
106 \funcline{__repeat__}{a, b}
6876
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
107 Return \var{a} \code{*} \var{b} where \var{a} is a sequence and
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
108 \var{b} is an integer.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
109 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
110
8418
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
111 \begin{funcdesc}{contains}{a, b}
14655
0228914e0c5f Added documentation for new functions.
Fred Drake <fdrake@acm.org>
parents: 10991
diff changeset
112 \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
113 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
114 Note the reversed operands. The name \function{__contains__()} was
0228914e0c5f Added documentation for new functions.
Fred Drake <fdrake@acm.org>
parents: 10991
diff changeset
115 added in Python 2.0.
0228914e0c5f Added documentation for new functions.
Fred Drake <fdrake@acm.org>
parents: 10991
diff changeset
116 \end{funcdesc}
0228914e0c5f Added documentation for new functions.
Fred Drake <fdrake@acm.org>
parents: 10991
diff changeset
117
0228914e0c5f Added documentation for new functions.
Fred Drake <fdrake@acm.org>
parents: 10991
diff changeset
118 \begin{funcdesc}{sequenceIncludes}{\unspecified}
0228914e0c5f Added documentation for new functions.
Fred Drake <fdrake@acm.org>
parents: 10991
diff changeset
119 \deprecated{2.0}{Use \function{contains()} instead.}
0228914e0c5f Added documentation for new functions.
Fred Drake <fdrake@acm.org>
parents: 10991
diff changeset
120 Alias for \function{contains()}.
8418
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
121 \end{funcdesc}
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
122
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
123 \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
124 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
125 \end{funcdesc}
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
126
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
127 \begin{funcdesc}{indexOf}{a, b}
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
128 Return the index of the first of occurrence 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
129 \end{funcdesc}
b5ff663ee76d Document missing functions: xor, not, truth, countOf, indexOf, and
Guido van Rossum <guido@python.org>
parents: 7877
diff changeset
130
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
131 \begin{funcdesc}{getitem}{a, b}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
132 \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
133 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
134 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
135
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
136 \begin{funcdesc}{setitem}{a, b, c}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
137 \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
138 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
139 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
140
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
141 \begin{funcdesc}{delitem}{a, b}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
142 \funcline{__delitem__}{a, b}
6876
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
143 Remove 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
144 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
145
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
146 \begin{funcdesc}{getslice}{a, b, c}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
147 \funcline{__getslice__}{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
148 Return the slice of \var{a} from index \var{b} to index \var{c}\code{-1}.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
149 \end{funcdesc}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
150
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
151 \begin{funcdesc}{setslice}{a, b, c, v}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
152 \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
153 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
154 sequence \var{v}.
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
6745
1db41ca45c7f Removed unnecessary escaping.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
157 \begin{funcdesc}{delslice}{a, b, c}
7603
c0bf9b60c298 Some logical markup.
Fred Drake <fdrake@acm.org>
parents: 7343
diff changeset
158 \funcline{__delslice__}{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
159 Delete the slice of \var{a} from index \var{b} to index \var{c}\code{-1}.
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
14965
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
162 The \module{operator} also defines a few predicates to test the type
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
163 of objects. \strong{Note:} Be careful not to misinterpret the
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
164 results of these functions; only \function{isCallable()} has any
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
165 measure of reliability with instance objects. For example:
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
166
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
167 \begin{verbatim}
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
168 >>> class C:
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
169 ... pass
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
170 ...
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
171 >>> import operator
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
172 >>> o = C()
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
173 >>> operator.isMappingType(o)
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
174 1
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
175 \end{verbatim}
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
176
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
177 \begin{funcdesc}{isCallable}{o}
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
178 \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
179 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
180 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
181 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
182 \method{__call__()} method.
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
183 \end{funcdesc}
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
184
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
185 \begin{funcdesc}{isMappingType}{o}
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
186 Returns true if the object \var{o} supports the mapping interface.
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
187 This is true for dictionaries and all instance objects.
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
188 \strong{Warning:} There is no reliable way to test if an instance
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
189 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
190 ill-defined. This makes this test less useful than it otherwise might
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
191 be.
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
192 \end{funcdesc}
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
193
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
194 \begin{funcdesc}{isNumberType}{o}
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
195 Returns true if the object \var{o} represents a number. This is true
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
196 for all numeric types implemented in C, and for all instance objects.
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
197 \strong{Warning:} There is no reliable way to test if an instance
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
198 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
199 ill-defined. This makes this test less useful than it otherwise might
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
200 be.
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
201 \end{funcdesc}
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
202
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
203 \begin{funcdesc}{isSequenceType}{o}
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
204 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
205 This returns true for all objects which define sequence methods in C,
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
206 and for all instance objects. \strong{Warning:} There is no reliable
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
207 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
208 since the interface itself is ill-defined. This makes this test less
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
209 useful than it otherwise might be.
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
210 \end{funcdesc}
1aa37008fd2c Add documentation and warnings for the isCallable(), isMappingType(),
Fred Drake <fdrake@acm.org>
parents: 14655
diff changeset
211
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
212
6876
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
213 Example: Build a dictionary that maps the ordinals from \code{0} to
4e2cc5044fa5 Descriptions for delitem(), __delitem__(): These delete a value, not set it.
Fred Drake <fdrake@acm.org>
parents: 6871
diff changeset
214 \code{256} to their character equivalents.
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
215
7277
bf4e790bd61a Remove all \bcode / \ecode cruft; this is no longer needed. See previous
Fred Drake <fdrake@acm.org>
parents: 6955
diff changeset
216 \begin{verbatim}
4610
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
217 >>> import operator
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
218 >>> d = {}
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
219 >>> keys = range(256)
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
220 >>> vals = map(chr, keys)
bb4094ff7bdf Added section for operator module (compiled Skip Montanaro).
Guido van Rossum <guido@python.org>
parents:
diff changeset
221 >>> 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
222 \end{verbatim}