<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def grid(self, grid):
 """Turns all gridlines on or off :param bool grid: turns the gridlines on if ``True``, off if ``False``"""


        if not isinstance(grid, bool):
            raise TypeError("grid must be boolean, not '%s'" % grid)
        self._x_grid = self._y_grid = grid