0

According to this documentation python has an operator @ that represents matmul to multiply matrices. I have used this operator with numpy, however, I think that Python should not be module-specific so there must be some way to make this work without numpy. I tried defining two 2D python lists

b = [list(range(10))]*3
a = [list(range(3))]*10

however when I tried doing a@b I got TypeError: unsupported operand type(s) for @: 'list' and 'list'. How do I use the @ operator without Numpy?

  • 5
    Did you read [this answer](https://stackoverflow.com/a/27385659/2320035) (`No builtin Python types implement this operator.`)? – sascha Aug 02 '19 at 11:03
  • You say you want to do matrix multiplication but you don't have any matrices in your example. In fact Python doesn't have any built-in `matrix` type, so matrix multiplication doesn't make much sense here. But of course you're free to implement your own :-) By the way `Ellipsis` is also mostly used by Numpy (though it found its application within Python, in the `typing` module for example). – a_guest Aug 02 '19 at 11:15
  • The answer essentially being: you can't unless you specifically define custom classes that can make use of it. – Paritosh Singh Aug 02 '19 at 11:33
  • Write a function maybe ... ? – phoxis Aug 04 '19 at 21:43

0 Answers0