def __getitem__(self, position):
        i, j = self._get_indexes(position)
        if isinstance(i, slice):
            if j is None:  # build sub-table w/ full rows
                return Table(self.data[position])
            else:  # build sub-table w/ sub-rows
                return Table(cells[j] for cells in self.data[i])
        else:  # i is number
            try:
                row = self.data[i]
            except IndexError:
                msg = 'no row at index %r of %d-row table'
                raise IndexError(msg % (position, len(self)))
            if j is None:  # return row at table[i]
                return row
            else:
                return row[j]  # return row[j] or row[a:b]
dataset/ETHPy150Open fluentpython/example-code/attic/sequences/table.py/Table.__getitem__/original