I am new to python. I want to write a class with two keys as an indexer. should also be able to use them inside the class as follows:
a = Cartesian(-10,-10,10,10) # Cartesian is the name of my class
a[-5][-1]=10
and in the Cartesian class:
def fill(self,value):
self[x][y] = x*y-value
I'm trying with
def __getitem__(self,x,y):
return self.data[x-self.dx][y-self.dy]
but does not work.
source
share