[Python-Dev] Re: accumulator display syntax
Nick Coghlan
ncoghlan at iinet.net.au
Tue Oct 21 09:41:39 EDT 2003
Guido van Rossum strung bits together to say:
> except compactness of exprssion. How frequent is
>
> result = 0.0
> for x in S:
> result += x**2
>
> ???
>
> (I've already said my -1 about your 'sum of ...' proposal.)
Just so this suggestion doesn't get buried in the part of the thread where I was
getting rather carried away about Greg's 'of' syntax (sorry!).
What about:
result + x**2 from result = 0.0 for x in S
Essentially short for:
result = 0.0
for x in S:
result = result + x**2
Cheers,
Nick.
--
Nick Coghlan | Brisbane, Australia
ICQ#: 68854767 | ncoghlan at email.com
Mobile: 0409 573 268 | http://www.talkinboutstuff.net
"Let go your prejudices,
lest they limit your thoughts and actions."
More information about the Python-Dev
mailing list