title: Pythonic way to iterate over sequence, 4 items at a time
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/434287/what-is-the-most-pythonic-way-to-iterate-over-a-list-in-chunks">What is the most &ldquo;pythonic&rdquo; way to iterate over a list in chunks?</a>  </p>
  </blockquote>
  
  
  
  <p>I am reading in some PNG data, which has 4 channels per pixel.  I would like to iterate over the data 1 pixel at a time (meaning every 4 elements = 1 pixel, rgba).</p>
  
  <pre><code>red_channel = 0
  while red_channel &lt; len(raw_png_data):
      green_channel, blue_channel, alpha_channel = red_channel +1, red_channel +2, red_channel +3
      # do something with my 4 channels of pixel data ... raw_png_data[red_channel] etc
      red_channel += 4
  </code></pre>
  
  <p>This way doesnt really seem "right".  Is there a more Pythonic way to iterate over a sequence, 4 items at a time, and have those 4 items unpacked?</p>