[Python-Dev] Re: Re: accumulator display syntax
Alex Martelli
aleaxit at yahoo.com
Tue Oct 21 03:43:31 EDT 2003
On Tuesday 21 October 2003 09:27 am, Greg Ewing wrote:
...
> But maybe some other keyword could be added to ease any
> syntactic problems, such as "all" or "every":
>
> sum(all x*x for x in xlist)
> sum(every x*x for x in xlist)
>
> The presence of the extra keyword would then distinguish
> an iterator comprehension from the innards of a list
> comprehension.
Heh, you ARE a volcano of cool syntactic ideas these days, Greg.
As between them, to me 'all' sort of connotes 'all at once' while
'every' connotes 'one by one' (so would a third possibility, 'each');
so 'all' is the one I like least.
Besides accumulators &c we should also think of normal loops:
for a in all x*x for x in xlist: ...
for a in every x*x for x in xlist: ...
for a in each x*x for x in xlist: ...
Of these three, 'every' looks best to me, personally.
Alex
More information about the Python-Dev
mailing list