Possible to use more than one argument on __getitem__?

前端 未结 3 1122
广开言路
广开言路 2020-12-06 04:12

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 p

3条回答
  •  温柔的废话
    2020-12-06 04:56

    No, __getitem__ just takes one argument (in addition to self). In the case of matrix[0, 0], the argument is the tuple (0, 0).

提交回复
热议问题