def previous_current_next(items):
 extend = itertools.chain([None], items, [None])
 (prev, cur, nex) = itertools.tee(extend, 3)
 next(cur)
 next(nex)
 next(nex)
 return zip(prev, cur, nex)

def previous_current_next ( items ) : extend = itertools . chain ( [ None ] , items , [ None ] ) ( prev , cur , nex ) = itertools . tee ( extend , 3 ) next ( cur ) next ( nex ) next ( nex ) return zip ( prev , cur , nex )
from URL creates an iterator which returns triples .