PEP368 and pixeliterators

Casey Webster Caseyweb at gmail.com
Thu Jul 2 08:17:28 EDT 2009


On Jul 2, 4:32 am, Joachim Strömbergson <Joac... at 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.



More information about the Python-list mailing list