def previous_current_next(items):
    """
    From http://www.wordaligned.org/articles/zippy-triples-served-with-python

    Creates an iterator which returns (previous, current, next) triples,
    with ``None`` filling in when there is no previous or next
    available.
    """
    extend = itertools.chain([None], items, [None])
    previous, current, next = itertools.tee(extend, 3)
    try:
        current.next()
        next.next()
        next.next()
    except __HOLE__:
        pass
    return itertools.izip(previous, current, next)
dataset/ETHPy150Open agiliq/django-socialnews/socialnews/mptt/utils.py/previous_current_next