Re: PEP368 and pixeliterators

2009-07-05 Thread Rhodri James
On Fri, 03 Jul 2009 09:21:09 +0100, Steven D'Aprano wrote: On Thu, 02 Jul 2009 10:32:04 +0200, Joachim Strömbergson wrote: for pixel in rgb_image: # swap red and blue, and set green to 0 pixel.value = pixel.b, 0, pixel.r The idea I'm having is that fundamentally the image is made

Re: PEP368 and pixeliterators

2009-07-03 Thread Steven D'Aprano
On Thu, 02 Jul 2009 10:32:04 +0200, Joachim Strömbergson wrote: > for pixel in rgb_image: > # swap red and blue, and set green to 0 pixel.value = pixel.b, 0, > pixel.r > > > The idea I'm having is that fundamentally the image is made up of a 2D > array of pixels, not rows of pixels. A 2

Re: PEP368 and pixeliterators

2009-07-02 Thread Nobody
On Thu, 02 Jul 2009 10:32:04 +0200, Joachim Strömbergson wrote: > I just read the PEP368 and really liked the proposed idea, sound like a > great battery addition to include in the std lib: > > http://www.python.org/dev/peps/pep-0368/ Unfortunately, it's too simplistic, meaning that most of the

Re: PEP368 and pixeliterators

2009-07-02 Thread Joachim Strömbergson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Aloha! Casey Webster wrote: > 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

Re: PEP368 and pixeliterators

2009-07-02 Thread Casey Webster
On Jul 2, 4:32 am, Joachim Strömbergson 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

PEP368 and pixeliterators

2009-07-02 Thread Joachim Strömbergson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Aloha! I just read the PEP368 and really liked the proposed idea, sound like a great battery addition to include in the std lib: http://www.python.org/dev/peps/pep-0368/ One question/idea though: The proposed iterator will iterate over all pixels in