def __getitem__(self, key):
        """Get a row, or a column, or a new table by slicing.

        Parameters
        ----------
        key : int, slice, str
            If key is an `int`, returns a row.
            If key is an `str`, returns iterator to a column with header `key`.
            If key is a slice object, returns a new table sliced according to
            rows.

        Raises
        ------
        TypeError
            If key is not of type int, slice or str.
        IndexError
            If `int` key is out of range.
        KeyError
            If `str` key is not found in headers.
        """
        if isinstance(key, slice):
            new_table = copy.copy(self)
            # Every child of BaseRow class needs to be reassigned so that
            # They contain reference of the new table rather than the old
            # This was a cause of a nasty bug once.
            new_table.column_headers = self.column_headers
            new_table.column_alignments = self.column_alignments
            new_table.column_widths = self.column_widths
            new_table.left_padding_widths = self.left_padding_widths
            new_table.right_padding_widths = self.left_padding_widths
            new_table._table = []
            for row in self._table[key]:
                new_table.append_row(row)
            return new_table
        elif isinstance(key, int):
            return self._table[key]
        elif isinstance(key, basestring):
            return self.get_column(key)
        else:
            raise TypeError(("table indices must be integers, strings or "
                             "slices, not {}").format(type(key).__name__))
def __getitem__ ( self , key ) : if isinstance ( key , slice ) : new_table = copy . copy ( self ) new_table . column_headers = self . column_headers new_table . column_alignments = self . column_alignments new_table . column_widths = self . column_widths new_table . left_padding_widths = self . left_padding_widths new_table . right_padding_widths = self . left_padding_widths new_table . _table = [ ] for row in self . _table [ key ] : new_table . append_row ( row ) return new_table elif isinstance ( key , int ) : return self . _table [ key ] elif isinstance ( key , basestring ) : return self . get_column ( key ) else : raise TypeError ( ( "table indices must be integers, strings or " "slices, not {}" ) . format ( type ( key ) . __name__ ) )
Get a row, or a column, or a new table by slicing.

        Parameters
        ----------
        key : int, slice, str
            If key is an `int`, returns a row.
            If key is an `str`, returns iterator to a column with header `key`.
            If key is a slice object, returns a new table sliced according to
            rows.

        Raises
        ------
        TypeError
            If key is not of type int, slice or str.
        IndexError
            If `int` key is out of range.
        KeyError
            If `str` key is not found in headers.