Operator Functions

operator.sub()

Subtract numeric operands or compute supported differences, such as set difference. Equivalent to a - b; custom operand types control the result.

Formal Syntax & Structure

python syntaxpython
operator.sub(a, b, /)

Parameters & Attributes

NameTypeDescription
aobjectLeft operand or target object.
bobjectRight operand.

Return Value

object

The object result described above.

Working Example

Example Snippetpython
import operatorprint(operator.sub(7, 3))
Python Reference