operator
operator — Standard operators as functions
The operator
module exports a set of efficient functions corresponding to the intrinsic operators of Python. For example, operator.add(x, y)
is equivalent to the expression x+y
. The function names are those used for special class methods; variants without leading and trailing __
are also provided for convenience.
The functions fall into categories that perform object comparisons, logical operations, mathematical operations, sequence operations, and abstract type tests.
The object comparison functions are useful for all objects, and are named after the rich comparison operators they support:
-
operator.lt(a, b)
<