Python Glossary Русский

Python 3.5+operatorfunction

operator.imatmul

in-place

In-place matrix multiplication: a @= b (invokes __imatmul__).

Syntax

operator.imatmul(a, b)

Built-in types do not support @=: imatmul([1], [2]) raises TypeError. It is meaningful for library arrays. If a class lacks __imatmul__, the call falls back to __matmul__ and returns a new object, leaving the original untouched — so, as with immutable types, assign the result.

Examples

import operator
class M:
    def __imatmul__(self, other): return 'imm'
print(operator.imatmul(M(), M()))   # → imm

See also

Open in the full glossarydocs.python.orgReport an inaccuracy