Newbie question about tuples and list comprehensions

William McBrine wmcbrine at users.sf.net
Thu Jun 26 03:13:10 CEST 2008


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 41 56 C5 63 56 88 C0 -- pass it on



More information about the Python-list mailing list