The problem is easy, I want to iterate over each element of the list and the next one in pairs (wrapping the last one with the first).
I\'ve thought about two unpyth
I, as always, like tee:
from itertools import tee, izip, chain def pairs(iterable): a, b = tee(iterable) return izip(a, chain(b, [next(b)]))