CKTIS / Python
Operator -=
Subtracts the right operand from the stored value and writes the difference back to the target.
Version: Python 3.14; repository image, production runtime not attested
Syntax
target -= valueSubtracts the right operand from the stored value and writes the difference back to the target.
Use this operation to decrement a balance or remove members from a mutable set. An integer value cannot be mutated, so the variable is rebound to the result.
An object can implement in-place subtraction; otherwise ordinary subtraction supplies the result. An unsupported operand pair raises a type error.
Integer subtraction can cross zero. The updated binding still holds an integer.
Syntax
target -= value
__isub__, __sub__, __rsub__ · TypeError
Worked example
n = 3; old = n; n -= 5
n → -2
old → 3
s = {2, 3}; alias = s; s -= {2}
alias → {3}
Examples
value = 11
value -= 14
print(value)
print(type(value).__name__)
Result
-3 int
Integer subtraction can cross zero. The updated binding still holds an integer.