def pcn_iter_core(self): """ yields triples of (previous,current,next) for every item in iterable, with None if there is no previous or next """ iterable = self.iterable h = HistoricalContext() yielded_anything = False for item in iterable: h.set_next(item) if h.current is not None: yield h.pcn_tuple() yielded_anything = True h.new_next() result = h.pcn_tuple() (p,c,n) = result if c is not None: yield result