Is there a nice Pythonic way to loop over a list, retuning a pair of elements? The last element should be paired with the first.
So for instance, if I have the list
from itertools import izip, chain, islice itr = izip(l, chain(islice(l, 1, None), islice(l, 1)))
(As above with @j-f-sebastian's "zip" answer, but using itertools.)
NB: EDITED given helpful nudge from @200_success. previously was:
itr = izip(l, chain(l[1:], l[:1]))