Operators¶
The Python operator module [0] contains a large variety of operators and
iteration_utilities
only tries to fill in some missing ones:
Reverse arithmetic operators¶
reciprocal()
, equivalent tolambda x: 1 / x
Function |
Equivalent |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
Math operators¶
double()
, equivalent tolambda x: x * 2
square()
, equivalent tolambda x: x ** 2
reciprocal()
, equivalent tolambda x: 1 / x
And of course the standard operators from the operator module:
Function |
Equivalent |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
And the bitwise operators:
Function |
Equivalent |
---|---|
|
|
|
|
|
|
|
|
|
|
|
Note
The math
module contains several more!
Comparison operators¶
is_even()
, equivalent tolambda x: (x % 2) == 0
.is_odd()
, equivalent tolambda x: (x % 2) != 0
.is_None()
, equivalent tolambda x: x is None
.is_not_None()
, equivalent tolambda x: x is not None
.is_iterable()
, roughly equivalent tolambda x: isinstance(x, collections.Iterable)
.
And the comparison operators from the Python library:
Function |
Equivalent |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Misc¶
And some misc operators
Function |
Equivalent |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Marked (*
) functions only have a rough equivalent and may be more
sophisticated!