python sliding window

def window(iterable, size=2):
    i = iter(iterable)
    win = []
    for e in range(0, size):
    yield win
    for e in i:
        win = win[1:] + [e]
        yield win

Here is what the above code is Doing:
1. Create a generator that will iterate over the iterable.
2. Create a list of the first size elements of the iterable.
3. Yield the list.
4. For each element in the iterable, remove the first element of the list and append the new element.
5. Yield the list.