def closed_pairwise(iterable):
    """ Return a generator which generate a closed pair wise list from an iterable.
    s -> (s[0],s[1]), (s[1],s[2]), ... (s[N], s[0])
    """
    closed_iterable = list(iterable) + [iterable[0]]
    prev = closed_iterable[0]
    for x in closed_iterable[1:]:
        yield prev, x
        prev = x
