A: 

Try something like this:

for red, green, blue, alpha in raw_png_data:
    #do something

You can pull out multiple items and never have to use an iterator. :)

Edit: This would mean that raw_png_data needs to be a list of 4 value tuples. It would be most pythonic to put each rgba group into a tuple and then append it to raw_png_data and iterate through like my example.

excid3
Obviously this will not work, unless raw_png_data is a list of tuples. Right?
Sjoerd
Yeah, but it would be a good idea when raw_png_data is created, to group them into tuples since each group of 4 values is related.
excid3
+5  A: 
vars = [1, 2, 3, 4, 5, 6, 7, 8]
for a, b, c, d in zip(*[iter(vars)]*4):
    print a, b, c, d
Tomasz Wysocki
+1 - my vote for "most Pythonic"
Paul McGuire
A: 
for r, g, b, t in (data[i:i+4] for i in xrange(0, len(data)/4*4, 4)):
    print r, g, b, t
Sjoerd
Not all sequences support indexing. `data` could very well be a generator.
ΤΖΩΤΖΙΟΥ
+8  A: 

(Python's itertools should really make all recipes as standard functions...)

You could use the grouper function:

from itertools import izip_longest
def grouper(n, iterable, fillvalue=None):
    "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
    args = [iter(iterable)] * n
    return izip_longest(fillvalue=fillvalue, *args)

Then you can iterate the pixels by

for r,g,b,a in grouper(4, raw_png_data):
  ....

Alternatively, you could use

irpd = iter(raw_png_data)
for r,g,b,a in zip(irpd, irpd, irpd, irpd):  # use itertools.izip in Python 2.x
  ....

Note that this will chop the last few bytes if the iterable's length is not a multiple of 4. OTOH, the grouper function uses izip_longest, so the extra bytes will be padded with None for that.

KennyTM
+1 for the right answer =p
katrielalex
+2  A: 
from itertools import izip
for r,g,b,a in izip(*[iter(data)]*4):
    ...
gnibbler