[Python-Dev] Re: "groupby" iterator
gball at cfa.harvard.edu
Wed Dec 3 11:18:21 EST 2003
Would it work to generalise generator expressions in the following way:
(x for x) == lambda x:x
(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
i.e. an anonymous block notation, with early binding semantics. It could
work as a lambda replacement. But no-argument lambdas would require some
(1 for) == lambda:1 # yuck!
(1 for ()) == lambda:1 # better?
And should this be allowed?
((a,b) for a in l for b,l) == lambda b,l: ((a,b) for a in l)
More information about the Python-Dev