def __getitem__(self, coord):

        x, y = coord

        if isinstance(x, slice) or isinstance(y, slice):
            if isinstance(x, slice):
                x_indices = x.indices(self.width)
            else:
                x_indices = [x]

            if isinstance(y, slice):
                y_indices = y.indices(self.height)
            else:
                y_indices = [y]

            try:
                wrap_x, wrap_y = self._wrap_functions

                ret = []

                for y_index in range(*y_indices):
                    nodes_y = self.nodes[ wrap_y(y_index) ]

                    for x_index in range(*x_indices):
                        ret.append( nodes_y[ wrap_x(x_index) ] )

            except IndexError:
                raise IndexError("Slice out of range")

            return ret


        x, y = self.wrap(coord)

        if x < 0 or y < 0:
            raise IndexError("coordinate out of range")

        try:
            return self.nodes[y][x]
        except __HOLE__:
            raise IndexError("coordinate out of range")
dataset/ETHPy150Open PythonProgramming/Beginning-Game-Development-with-Python-and-Pygame/gameobjects/grid.py/Grid.__getitem__