|
|
Whole document tree
3.10.1 Mapping Operators to Functions
3.10.1 Mapping Operators to Functions
This table shows how abstract operations correspond to operator
symbols in the Python syntax and the functions in the
operator module.
Addition |
a + b |
add(a, b) |
Concatenation |
seq1 + seq2 |
concat(seq1, seq2) |
Containment Test |
o in seq |
contains(seq, o) |
Division |
a / b |
div(a, b) |
Bitwise And |
a & b |
and_(a, b) |
Bitwise Exclusive Or |
a ^ b |
xor(a, b) |
Bitwise Inversion |
~ a |
invert(a) |
Bitwise Or |
a | b |
or_(a, b) |
Indexed Assignment |
o[k] = v |
setitem(o, k, v) |
Indexed Deletion |
del o[k] |
delitem(o, k) |
Indexing |
o[k] |
getitem(o, k) |
Left Shift |
a << b |
lshift(a, b) |
Modulo |
a % b |
mod(a, b) |
Multiplication |
a * b |
mul(a, b) |
Negation (Arithmetic) |
- a |
neg(a) |
Negation (Logical) |
not a |
not_(a) |
Right Shift |
a >> b |
rshift(a, b) |
Sequence Repitition |
seq * i |
repeat(seq, i) |
Slice Assignment |
seq[i:j] = values |
setslice(seq, i, j, values) |
Slice Deletion |
del seq[i:j] |
delslice(seq, i, j) |
Slicing |
seq[i:j] |
getslice(seq, i, j) |
String Formatting |
s % o |
mod(s, o) |
Subtraction |
a - b |
sub(a, b) |
Truth Test |
o |
truth(o) |
See About this document... for information on suggesting changes.
|