π₯ TRENDING: /library/operator.html - Uncensored 2025
operator β Standard operators as functionsΒΆ
Source code: Lib/operator.py
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. Many function names are those used for
special methods, without the double underscores. For backward compatibility,
many of these have a variant with the double underscores kept. The variants
without the double underscores are preferred for clarity.
The functions fall into categories that perform object comparisons, logical operations, mathematical operations and sequence operations.
The object comparison functions are useful for all objects, and are named after the rich comparison operators they support: