[Python-Dev] Re: accumulator display syntax

Guido van Rossum guido at python.org
Wed Oct 22 12:05:58 EDT 2003


> 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/)



More information about the Python-Dev mailing list