IPython Documentation

Table Of Contents

Previous topic


Next topic


This Page


Module: utils.data

Utilities for working with data structures like lists, dicts and tuples.


IPython.utils.data.chop(seq, size)

Chop a sequence into chunks of the given size.


Flatten a list of lists (NOT recursive, only works for 2d lists).

IPython.utils.data.get_slice(seq, start=0, stop=None, step=1)

Get a slice of a sequence with variable step. Specify start,stop,step.


Takes a list of (key,value) pairs and turns it into a dict.

IPython.utils.data.list2dict2(lst, default='')

Takes a list and turns it into a dict. Much slower than list2dict, but more versatile. This version can take lists with sublists of arbitrary length (including sclars).

IPython.utils.data.sort_compare(lst1, lst2, inplace=1)

Sort and compare two lists.

By default it does it in place, thus modifying the lists. Use inplace = 0 to avoid that (at the cost of temporary copy creation).

IPython.utils.data.uniq_stable(elems) → list

Return from an iterable, a list of all the unique elements in the input, but maintaining the order in which they first appear.

Note: All elements in the input must be hashable for this routine to work, as it internally uses a set for efficiency reasons.