title: Iteration over list slices
body: <p>I want an algorithm to iterate over list slices. Slices size is set outside the function and can differ.</p>
  <p>In my mind it is something like:</p>
  <pre><code>for list_of_x_items in fatherList:
      foo(list_of_x_items)
  </code></pre>
  <p>Is there a way to properly define <code>list_of_x_items</code> or some other way of doing this using python 2.5?</p>
  <hr />
  <p><strong>edit1: Clarification</strong> Both &quot;partitioning&quot; and &quot;sliding window&quot; terms sound applicable to my task, but I am no expert. So I will explain  the problem a bit deeper and add to the question:</p>
  <p>The fatherList is a multilevel numpy.array I am getting from a file. Function has to find averages of series (user provides the length of series) For averaging I am using the <code>mean()</code> function. Now for question expansion:</p>
  <p><strong>edit2:</strong> How to modify the function you have provided to store the extra items and use them when the next fatherList is fed to the function?</p>
  <p>for example if the list is lenght 10 and size of a chunk is 3, then the 10th member of the list is stored and appended to the beginning of the next list.</p>
  <hr />
  <h3>Related:</h3>
  <ul>
  <li><a href="https://stackoverflow.com/questions/434287/what-is-the-most-pythonic-way-to-iterate-over-a-list-in-chunks">What is the most “pythonic” way to iterate over a list in chunks?</a></li>
  </ul>