<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_cursor(self, value):
 """Changes the grid cursor cell. Parameters value: 2-tuple or 3-tuple of String \trow, col, tab or row, col for target cursor position """


        shape = self.grid.code_array.shape

        if len(value) == 3:
            self.grid._last_selected_cell = row, col, tab = value
            if row < 0 or col < 0 or tab < 0 or \
               row >= shape[0] or col >= shape[1] or tab >= shape[2]:
                raise ValueError("Cell {value} outside of {shape}".format(
                                 value=value, shape=shape))

            if tab != self.cursor[2]:
                post_command_event(self.main_window,
                                   self.GridActionTableSwitchMsg, newtable=tab)
                if is_gtk():
                    try:
                        wx.Yield()
                    except:
                        pass
        else:
            row, col = value
            if row < 0 or col < 0 or row >= shape[0] or col >= shape[1]:
                raise ValueError("Cell {value} outside of {shape}".format(
                                 value=value, shape=shape))

            self.grid._last_selected_cell = row, col, self.grid.current_table

        if not (row is None and col is None):
            if not self.grid.IsVisible(row, col, wholeCellVisible=True):
                self.grid.MakeCellVisible(row, col)
            self.grid.SetGridCursor(row, col)