Function Versions of Standard Operators

Learn when to use standard operators in Python with the help of the examples provided.

The standard operator module contains a set of functions that are equivalent to Python operators. For example:

x = operator.add(a, b) # Equivalent to x = a + b
x = operator.truediv(a, b) # Equivalent to x = a / b
x = operator.floordiv(a, b) # Equivalent to x = a // b

Get hands-on with 1200+ tech skills courses.