all Python 3operatorfunction
operator.ipow
in-place
In-place exponentiation: a **= b.
Syntax
operator.ipow(a, b)
For ints the result is exact and may be huge: ipow(2, 100) is a 31-digit number with no overflow. A negative exponent on an int yields a float: ipow(2, -1) is 0.5. There is no modular exponentiation like the three-argument pow(base, exp, mod) — use pow for cryptography and large powers modulo n.
Examples
import operator
print(operator.ipow(2, 3)) # → 8
print(operator.ipow(2, -1)) # → 0.5
print(operator.ipow(9, 0.5)) # → 3.0
base = 3 # ни один встроенный тип не меняется по **= — присваивайте результат
print(operator.ipow(base, 4), base) # → 81 3
print(operator.ipow(2, 10, 1000)) # → TypeError
See also
Open in the full glossarydocs.python.orgReport an inaccuracy