ipython/ipython — pull request #1875 by Carreau (2012-06-07 08:25:19+00:00)
Title: re-write columnize, with intermediate step.

fix test that where wrong, add some others.

fix #1860

--

Maybe not the fastest implementation ever, but allow some granularity, and intermediate state i'll need for #1851. More over, it does more in less lines (docstrings and test excluded :-) ).
Nice thing with this granularity is that we could add stretching separators in one line if necessary.

Right now, it finds the right number of columns by bruteforcing,
we could try to bisect if we start hitting high number of items, but i'm not sure it is necessary.

Output of the new and old function were identical on around 20000 random test case, except when the old columnize was wrong (wider output than displaywidth).

I added a random test to hopefully catch edges cases (fail with a few percent probability on old columnize, haven't failed with new in thousand of sample) .

As it is a random test, I wasn't sure on how to keep information about it, so I added print statements and `assert False` is there a better way ?