[Python-Dev] Re: "groupby" iterator

Greg Ewing greg at cosc.canterbury.ac.nz
Wed Dec 3 22:22:49 EST 2003


Greg Ball <gball at cfa.harvard.edu>:

> (x[1] for x) == lambda x:x[1]
> (x.score for x) == lambda x: x.score
> (x+y for x,y) == lambda x,y: x+y
> (len(x) for x) == lambda x,len=len: len(x)  # roughly equivalent

Interesting idea, but it reads a bit strangely.

Maybe this would work better with a different keyword...

  x[1] given x
  x.score given x
  x+y given x,y
  len(x) given x

  stuff = groupby((x for x in seq), key = (x.score given x))

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