def fields(self, *fields):
        if len(fields) == 0:
            return [el.split() for el in self]

        res = SList()
        for el in [f.split() for f in self]:
            lineparts = []

            for fd in fields:
                try:
                    lineparts.append(el[fd])
                except IndexError:
                    pass
            if lineparts:
                res.append(" ".join(lineparts))

        return res
Collect whitespace-separated fields from string list
dataset/ETHPy150Open ipython/ipython-py3k/IPython/utils/text.py/SList.fields