[Python-Dev] Re: "groupby" iterator

Phillip J. Eby pje at telecommunity.com
Wed Dec 3 11:30:35 EST 2003

At 11:18 AM 12/3/03 -0500, Greg Ball wrote:
>Would it work to generalise generator expressions in the following way:
>(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

-1.  It looks like a generator expression, but the semantics are way too 
different.  Unless you intended that it should be invoked with .next() 
rather than __call__, but then there's no way to pass the arguments.

(FWIW, my first reaction was, "Whoa!  Cool!", until I thought about how 
you'd actually have to use it.)

More information about the Python-Dev mailing list