how to iterate from a specific point in a sequence (Python)
Question: **[Edit]**

From the feedback/answers I have received, I gather there is some confusion
regarding the original question. Consequently, I have reduced the problem to
its most rudimentary form

Here are the relevant facts of the problem:

  1. I have a sorted sequence: **S**
  2. I have an item (denoted by **_i_**) that is GUARANTEED to be contained in **S**
  3. I want a **find()** algorithm that returns an iterator (**_iter_**) that points to **_i_**
  4. After obtaining the iterator, I want to be able to iterate FORWARD (BACKWARD?) over the elements in **_S_** , starting FROM (and including) **_i_**

For my fellow C++ programmers who can also program in Python, what I am asking
for, is the equivalent of:

    
    
    const_iterator std::find (const key_type& x ) const;
    

The iterator returned can then be used to iterate the sequence. I am just
trying to find (pun unintended), if there is a similar inbuilt algorithm in
Python, to save me having to reinvent the wheel.


Answer: yes , you can do like this:

    
    
    import itertools
    from datetime import datetime
    
    data = {
          "2008-11-10 17:53:59":"data",
          "2005-11-10 17:53:59":"data",
    }
    
    list_ = data.keys()
    new_list = [datetime.strptime(x, "%Y-%m-%d %H:%M:%S") for x in list_]
    
    begin_date = datetime.strptime("2007-11-10 17:53:59", "%Y-%m-%d %H:%M:%S")
    
    for i in itertools.ifilter(lambda x: x > begin_date, new_list):
        print i
    

