11% Contributed by Skip Montanaro, from the module's doc strings.
22
3- \section {Built-in Module \sectcode {operator} } % If implemented in C
3+ \section {Built-in Module \sectcode {operator} }
44\bimodindex {operator}
55
66The \code {operator} module exports a set of functions implemented in C
77corresponding to the intrinsic operators of Python. For example,
8- {}\code {operator.add(x, y)} is equivalent to the expression x+y. The
8+ {}\code {operator.add(x, y)} is equivalent to the expression \code { x+y} . The
99function names are those used for special class methods; variants without
1010leading and trailing \samp {__} are also provided for convenience.
1111
@@ -14,175 +14,179 @@ \section{Built-in Module \sectcode{operator}} % If implemented in C
1414\renewcommand {\indexsubitem }{(in module operator)}
1515
1616\begin {funcdesc }{add}{a, b}
17- Return a + b , for a and b numbers.
17+ Return \var {a} \code {+} \var {b} , for \var {a} and \var {b} numbers.
1818\end {funcdesc }
1919
2020\begin {funcdesc }{__add__}{a, b}
21- Return a + b , for a and b numbers.
21+ Return \var {a} \code {+} \var {b} , for \var {a} and \var {b} numbers.
2222\end {funcdesc }
2323
2424\begin {funcdesc }{sub}{a, b}
25- Return a - b .
25+ Return \var {a} \code {-} \var {b} .
2626\end {funcdesc }
2727
2828\begin {funcdesc }{__sub__}{a, b}
29- Return a - b .
29+ Return \var {a} \code {-} \var {b} .
3030\end {funcdesc }
3131
3232\begin {funcdesc }{mul}{a, b}
33- Return a * b , for a and b numbers.
33+ Return \var {a} \code {*} \var {b} , for \var {a} and \var {b} numbers.
3434\end {funcdesc }
3535
3636\begin {funcdesc }{__mul__}{a, b}
37- Return a * b , for a and b numbers.
37+ Return \var {a} \code {*} \var {b} , for \var {a} and \var {b} numbers.
3838\end {funcdesc }
3939
4040\begin {funcdesc }{div}{a, b}
41- Return a / b .
41+ Return \var {a} \code {/} \var {b} .
4242\end {funcdesc }
4343
4444\begin {funcdesc }{__div__}{a, b}
45- Return a / b .
45+ Return \var {a} \code {/} \var {b} .
4646\end {funcdesc }
4747
4848\begin {funcdesc }{mod}{a, b}
49- Return a \% b .
49+ Return \var {a} \code { \% } \var {b} .
5050\end {funcdesc }
5151
5252\begin {funcdesc }{__mod__}{a, b}
53- Return a \% b .
53+ Return \var {a} \code { \% } \var {b} .
5454\end {funcdesc }
5555
5656\begin {funcdesc }{neg}{o}
57- Return o negated.
57+ Return \var {o} negated.
5858\end {funcdesc }
5959
6060\begin {funcdesc }{__neg__}{o}
61- Return o negated.
61+ Return \var {o} negated.
6262\end {funcdesc }
6363
6464\begin {funcdesc }{pos}{o}
65- Return o positive.
65+ Return \var {o} positive.
6666\end {funcdesc }
6767
6868\begin {funcdesc }{__pos__}{o}
69- Return o positive.
69+ Return \var {o} positive.
7070\end {funcdesc }
7171
7272\begin {funcdesc }{abs}{o}
73- Return the absolute value of o .
73+ Return the absolute value of \var {o} .
7474\end {funcdesc }
7575
7676\begin {funcdesc }{__abs__}{o}
77- Return the absolute value of o .
77+ Return the absolute value of \var {o} .
7878\end {funcdesc }
7979
8080\begin {funcdesc }{inv}{o}
81- Return the inverse of o .
81+ Return the inverse of \var {o} .
8282\end {funcdesc }
8383
8484\begin {funcdesc }{__inv__}{o}
85- Return the inverse of o .
85+ Return the inverse of \var {o} .
8686\end {funcdesc }
8787
8888\begin {funcdesc }{lshift}{a, b}
89- Return a shifted left by b .
89+ Return \var {a} shifted left by \var {b} .
9090\end {funcdesc }
9191
9292\begin {funcdesc }{__lshift__}{a, b}
93- Return a shifted left by b .
93+ Return \var {a} shifted left by \var {b} .
9494\end {funcdesc }
9595
9696\begin {funcdesc }{rshift}{a, b}
97- Return a shifted right by b .
97+ Return \var {a} shifted right by \var {b} .
9898\end {funcdesc }
9999
100100\begin {funcdesc }{__rshift__}{a, b}
101- Return a shifted right by b .
101+ Return \var {a} shifted right by \var {b} .
102102\end {funcdesc }
103103
104104\begin {funcdesc }{and_}{a, b}
105- Return the bitwise and of a and b .
105+ Return the bitwise and of \var {a} and \var {b} .
106106\end {funcdesc }
107107
108108\begin {funcdesc }{__and__}{a, b}
109- Return the bitwise and of a and b .
109+ Return the bitwise and of \var {a} and \var {b} .
110110\end {funcdesc }
111111
112112\begin {funcdesc }{or_}{a, b}
113- Return the bitwise or of a and b .
113+ Return the bitwise or of \var {a} and \var {b} .
114114\end {funcdesc }
115115
116116\begin {funcdesc }{__or__}{a, b}
117- Return the bitwise or of a and b .
117+ Return the bitwise or of \var {a} and \var {b} .
118118\end {funcdesc }
119119
120120\begin {funcdesc }{concat}{a, b}
121- Return a + b for a and b sequences.
121+ Return \var {a} \code {+} \var {b} for \var {a} and \var {b} sequences.
122122\end {funcdesc }
123123
124124\begin {funcdesc }{__concat__}{a, b}
125- Return a + b for a and b sequences.
125+ Return \var {a} \code {+} \var {b} for \var {a} and \var {b} sequences.
126126\end {funcdesc }
127127
128128\begin {funcdesc }{repeat}{a, b}
129- Return a * b where a is a sequence and b is an integer.
129+ Return \var {a} \code {*} \var {b} where \var {a} is a sequence and
130+ \var {b} is an integer.
130131\end {funcdesc }
131132
132133\begin {funcdesc }{__repeat__}{a, b}
133- Return a * b where a is a sequence and b is an integer.
134+ Return \var {a} \code {*} \var {b} where \var {a} is a sequence and
135+ \var {b} is an integer.
134136\end {funcdesc }
135137
136138\begin {funcdesc }{getitem}{a, b}
137- Return the value of a at index b .
139+ Return the value of \var {a} at index \var {b} .
138140\end {funcdesc }
139141
140142\begin {funcdesc }{__getitem__}{a, b}
141- Return the value of a at index b .
143+ Return the value of \var {a} at index \var {b} .
142144\end {funcdesc }
143145
144146\begin {funcdesc }{setitem}{a, b, c}
145- Set the value of a at index b to c .
147+ Set the value of \var {a} at index \var {b} to \var {c} .
146148\end {funcdesc }
147149
148150\begin {funcdesc }{__setitem__}{a, b, c}
149- Set the value of a at index b to c .
151+ Set the value of \var {a} at index \var {b} to \var {c} .
150152\end {funcdesc }
151153
152154\begin {funcdesc }{delitem}{a, b}
153- Set the value of a at index b .
155+ Remove the value of \var {a} at index \var {b} .
154156\end {funcdesc }
155157
156158\begin {funcdesc }{__delitem__}{a, b}
157- Set the value of a at index b .
159+ Remove the value of \var {a} at index \var {b} .
158160\end {funcdesc }
159161
160162\begin {funcdesc }{getslice}{a, b, c}
161- Return the slice of a from index b to index c-1 .
163+ Return the slice of \var {a} from index \var {b} to index \var {c} \code {-1} .
162164\end {funcdesc }
163165
164166\begin {funcdesc }{__getslice__}{a, b, c}
165- Return the slice of a from index b to index c-1 .
167+ Return the slice of \var {a} from index \var {b} to index \var {c} \code {-1} .
166168\end {funcdesc }
167169
168170\begin {funcdesc }{setslice}{a, b, c, v}
169- Set the slice of a from index b to index c-1 to the sequence v.
171+ Set the slice of \var {a} from index \var {b} to index \var {c}\code {-1} to the
172+ sequence \var {v}.
170173\end {funcdesc }
171174
172175\begin {funcdesc }{__setslice__}{a, b, c, v}
173- Set the slice of a from index b to index c-1 to the sequence v.
176+ Set the slice of \var {a} from index \var {b} to index \var {c}\code {-1} to the
177+ sequence \var {v}.
174178\end {funcdesc }
175179
176180\begin {funcdesc }{delslice}{a, b, c}
177- Delete the slice of a from index b to index c-1 .
181+ Delete the slice of \var {a} from index \var {b} to index \var {c} \code {-1} .
178182\end {funcdesc }
179183
180184\begin {funcdesc }{__delslice__}{a, b, c}
181- Delete the slice of a from index b to index c-1 .
185+ Delete the slice of \var {a} from index \var {b} to index \var {c} \code {-1} .
182186\end {funcdesc }
183187
184- Example: Build a dictionary that maps the ordinals from 0 to 256 to their
185- character equivalents.
188+ Example: Build a dictionary that maps the ordinals from \code {0} to
189+ \code {256} to their character equivalents.
186190
187191\bcode \begin {verbatim }
188192>>> import operator
0 commit comments