def __init__(self,it,countprevious,countcomingnext):
        '''initializes the iterator
        it: the underlying iterator
        countprevious: number of elements to keep after being visited
        countcomingnext: number of elements to look ahead
        '''
        self.iter=iter(it)
        # current element
        self.current=None
        self.existcurrent=False
        # list of previous and next elements
        self.comingnext=collections.deque()
        self.previous=collections.deque()
        self.countprevious=countprevious
        try:
            for i in range(countcomingnext):
                self.comingnext.append(self.iter.next())
        except StopIteration:
            pass
initializes the iterator
        it: the underlying iterator
        countprevious: number of elements to keep after being visited
        countcomingnext: number of elements to look ahead
        
recipes/Python/544296_iterator_with_context/recipe-544296.py