Reputation: 302
I am trying to figure out how to use matrix multiplication, operator @ in Python, listed in https://docs.python.org/3/reference/expressions.html, but I can´t find any example or make it work with lists.
How to use it?
Upvotes: 2
Views: 148
Reputation: 29936
Currently no builtin type uses the @
operator. You can define your own types to implement it by the __matmul__
magic word. Here is a basic example:
class Mx:
def __matmul__(self, other):
return "matmul {0} {1}".format(self, other)
print(Mx() @ 0)
Upvotes: 1