Re: Newbie question about tuples and list comprehensions

2008-06-26 Thread Peter Otten
idiolect wrote: > On Jun 25, 7:26 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: >> idiolect wrote: >> > Hi all - Sorry to plague you with another newbie question from a >> > lurker. Hopefully, this will be simple. >> >> > I have a list full of RGB pixel values read from an image. I want to >> > tes

Re: Newbie question about tuples and list comprehensions

2008-06-25 Thread William McBrine
On Wed, 25 Jun 2008 16:02:52 -0700, John Machin wrote: > Here's one approach (requires Python 2.5 or later): > [(50 if x < 50 else x, 50 if y < 50 else y, 50 if z < 50 else z) for > (x, y, z) in source] [(max(x, 50), max(y, 50), max(z, 50)) for (x, y, z) in source] -- 09 F9 11 02 9D 74 E3 5B D8

Re: Newbie question about tuples and list comprehensions

2008-06-25 Thread idiolect
On Jun 25, 7:26 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > idiolect wrote: > > Hi all - Sorry to plague you with another newbie question from a > > lurker. Hopefully, this will be simple. > > > I have a list full of RGB pixel values read from an image. I want to > > test each RGB band value per

Re: Newbie question about tuples and list comprehensions

2008-06-25 Thread Terry Reedy
idiolect wrote: Hi all - Sorry to plague you with another newbie question from a lurker. Hopefully, this will be simple. I have a list full of RGB pixel values read from an image. I want to test each RGB band value per pixel, and set it to something else if it meets or falls below a certain

Re: Newbie question about tuples and list comprehensions

2008-06-25 Thread Roger Miller
First, I second Matt's comment about using a boring old for loop when it is the simplest way to express what you want to do. Being Pythonic is not about using exotic features to scrunch your code down to a cool one-liner. It is about expressing your intentions in a simple, direct way. Sometimes

Re: Newbie question about tuples and list comprehensions

2008-06-25 Thread John Machin
On Jun 26, 7:37 am, idiolect <[EMAIL PROTECTED]> wrote: > Hi all - Sorry to plague you with another newbie question from a > lurker. Hopefully, this will be simple. > > I have a list full of RGB pixel values read from an image. I want to > test each RGB band value per pixel, and set it to somethi

Re: Newbie question about tuples and list comprehensions

2008-06-25 Thread Matimus
On Jun 25, 2:37 pm, idiolect <[EMAIL PROTECTED]> wrote: > Hi all - Sorry to plague you with another newbie question from a > lurker.  Hopefully, this will be simple. > > I have a list full of RGB pixel values read from an image.  I want to > test each RGB band value per pixel, and set it to somethi

Newbie question about tuples and list comprehensions

2008-06-25 Thread idiolect
Hi all - Sorry to plague you with another newbie question from a lurker. Hopefully, this will be simple. I have a list full of RGB pixel values read from an image. I want to test each RGB band value per pixel, and set it to something else if it meets or falls below a certain threshold - i.e., a