I am trying to use
__getitem__(self, x, y):
on my Matrix class, but it seems to me it doesn’t work (I still don’t know very well to use python).
I’m calling it like this:
print matrix[0,0]
Is it possible at all to use more than one argument? Thanks. Maybe I can use only one argument but pass it as a tuple?
__getitem__only accepts one argument (other thanself), so you get passed a tuple.You can do this:
outputs
See the documentation for
object.__getitem__for more information.