# 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¶

Function

Equivalent

`radd()`

`lambda x, y: y + x`

`rsub()`

`lambda x, y: y - x`

`rmul()`

`lambda x, y: y * x`

`rdiv()`

`lambda x, y: y / x`

`rfdiv()`

`lambda x, y: y // x`

`rpow()`

`lambda x, y: y ** x`

`rmod()`

`lambda x, y: y % x`

## Math operators¶

And of course the standard operators from the operator module:

Function

Equivalent

`operator.add()` (iadd)

`lambda x, y: x + y`

`operator.sub()` (isub)

`lambda x, y: x - y`

`operator.mul()` (imul)

`lambda x, y: x * y`

`operator.truediv()` (itruediv)

`lambda x, y: x / y`

`operator.floordiv()` (ifloordiv)

`lambda x, y: x // y`

`operator.pow()` (ipow)

`lambda x, y: x ** y`

`operator.mod()` (imod)

`lambda x, y: x % y`

`operator.matmul()` (imatmul)

`lambda x, y: x @ y`

`operator.abs()`

`lambda x: abs(x)`

`operator.pos()`

`lambda x: +x`

`operator.neg()`

`lambda x: -x`

And the bitwise operators:

Function

Equivalent

`operator.lshift()` (ilshift)

`lambda x, y: x << y`

`operator.rshift()` (irshift)

`lambda x, y: x >> y`

`lambda x, y: x & y`

`lambda x, y: x | y`

`operator.xor()` (ixor)

`lambda x, y: x ^ y`

`operator.inv()`

`lambda x: ~x`

Note

The `math` module contains several more!

## Comparison operators¶

And the comparison operators from the Python library:

Function

Equivalent

`operator.lt()`

`lambda x, y: x < y`

`operator.le()`

`lambda x, y: x <= y`

`operator.eq()`

`lambda x, y: x == y`

`operator.ne()`

`lambda x, y: x |= y`

`operator.ge()`

`lambda x, y: x >= y`

`operator.gt()`

`lambda x, y: x < y`

`operator.is_()`

`lambda x, y: x is y`

`operator.is_not()`

`lambda x, y: x is not y`

`operator.truth()`

`lambda x: not not x`

`operator.not_()`

`lambda x: not x`

## Misc¶

And some misc operators

Function

Equivalent

`lambda x: x__index__()`

`operator.concat()` (iconcat) *

`lambda x, y: x + y`

`operator.contains()`

`lambda x, y: y in x`

`lambda x, y: y.count(x)`

`lambda x, y: y.index(x)`

`operator.getitem()`

`lambda x, y: x[y]`

`operator.setitem()`

`lambda x, y, z: x[y] = z`

`operator.delitem()`

`lambda x, y: del x[y]`

`lambda x, lambda y: y[x]`

`lambda x, lambda y: y.x`

`lambda x, lambda y: y.x()`

`lambda x, y: len(x) or x.__length_hint__() or y`

Marked (`*`) functions only have a rough equivalent and may be more sophisticated!

### References¶

0

https://docs.python.org/library/operator.html