[Python-Dev] Re: accumulator display syntax

Greg Ewing greg at cosc.canterbury.ac.nz
Mon Oct 20 00:44:45 EDT 2003


Guido on iterator comprehensions:

> The real issue is whether it adds enough to make it worthwhile to
> change the language (again).
> 
> My current opinion is that it isn't

Maybe it's time to get back to what started all this, which
was a desire for an accumulation syntax. (Actually it was
a proposal to abuse a proposed accumulation syntax to get
sorting, if I remember correctly, but let's ignore that
detail for now...)

Most of us seem to agree that having list comprehensions 
available as a replacement for map() and filter() is a good
thing. But what about reduce()? Are there equally strong
reasons for wanting an alternative to that, too? If not,
why not?

And if we do, maybe a general iterator comprehension
syntax isn't the best way to go. It seemed that way at
first, but that seems to have led us into a bit of a
quagmire.

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

etc.?

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+



More information about the Python-Dev mailing list