bor.borygmus

A programming weblog by Hao Lian. • A long walk through an angry forest. • A series of memory leaks brought on by senility.

The setup.

>>> a = range(1, 6)
>>> a
[1, 2, 3, 4, 5]

The take.

>>> zip(a, a, a)
[(0, 0, 0), (1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5)]

The con.

>>> i = iter(a)
>>> zip(i, i, i)
[(0, 1, 2), (3, 4, 5)]

The explanation.

David Jones makes group soup out of these lemons. Since zip and iter are both implemented in C, this is one of the fastest and tersest ways to group.

[(January 30, 2009) .]

Mikael Sjödin (pictured here showering) has written a pager library provides paging function alternatives in Emacs so that the sequence (page-up, page-down) preserves cursor location. Like every other textbox widget in the world. (via Artur Hefczyc’s .emacs)

[(January 18, 2009) .]