consecutive('ABCDEF', 3) --> ABC BCD CDE DEF
    consecutive(itertools.cycle(iter), n) to get looped sequence

def consecutive(iterable, n):
    """
    consecutive('ABCDEF', 3) --> ABC BCD CDE DEF
    consecutive(itertools.cycle(iter), n) to get looped sequence
    """
    iterators = itertools.tee(iterable, n)
    for i, it in enumerate(iterators):
        for _ in range(i):
            next(it, None)
    return zip(*iterators)