On Jul 2, 4:32 am, Joachim Strömbergson <joac...@strombergson.com> wrote: > But, wouldn't it be more Pythonic and simpler to have an iterator that > iterates over all pixels in an image? Starting with upper left corner > and moving left-right and (line by line) to lower right. This would > change the code above to:
Unless I'm totally misreading the PEP, the author does provide both iterators. Quoting the PEP: Non-planar images offer the following additional methods: pixels() -> iterator[pixel] Returns an iterator that iterates over all the pixels in the image, starting from the top line and scanning each line from left to right. See below for a description of the pixel objects. __iter__() -> iterator[line] Returns an iterator that iterates over all the lines in the image, from top to bottom. See below for a description of the line objects. -- http://mail.python.org/mailman/listinfo/python-list