[Python-Dev] Re: accumulator display syntax

Alex Martelli aleaxit at yahoo.com
Mon Oct 20 04:07:46 EDT 2003


On Monday 20 October 2003 06:44 am, Greg Ewing wrote:
   ...
> So, taking the original accumulator display idea, and
> incorporating some of the ideas that have come up along
> the way, such as getting rid of the square brackets,
> how about
>
>   sum of x*x for x in xvalues
>   average of g for g in grades
>   maximum of f(x, y) for x in xrange for y in yrange
>   top(10) of humour(joke) for joke in comedy

Wow.

I'm speechless.

[later, having recovered speech] IF (big if) we could pull THAT off, it
WOULD be well worth making 'of' a keyword (and thus requiring a
"from __future__ import").  It's SO beautiful, SO pythonic, the only
risk I can see is that we'd have newbie people coding:
    sum of the_values
rather than:
    sum(the_values)
or:
    sum of x for x in the_values

We could (and hopefully will) quibble about the corresponding
semantics (particularly for the top(10) example, implicitly requiring
some "underlying sequence" to be made available while all other
uses require no such black magic).
But this is the first proposed new syntax I've seen in a long time --
not just on this thread -- that is SO pretty it makes me want it
in the language FOR ITSELF -- to reinforce the "Python is executable
pseudocode" idea!!! -- rather than just as a means to the end of
having the underlying semantics available.

I can but hope others share my fascination with it... in any case,
whatever happens to it, *BRAVO*, Greg!!!


Alex




More information about the Python-Dev mailing list