
Oct. 22, 2003
4:05 p.m.
I had a similar thought about 5 minutes after turning my computer off last night. The alternative I came up with was:
y = (from result = 0.0 do result += x**2 for x in values if x > 0)
I think you're aiming for the wrong thing here; I really see no reason why you'd want to avoid writing this out as a real for loop if you don't have an existing accumulator function (like sum()) to use. --Guido van Rossum (home page: http://www.python.org/~guido/)