At 16:22 04.12.2003 +1300, Greg Ewing wrote: >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)) on the plus side it nicely parallels generator expressions and the keyword makes lookup in the docs easy. On the minus side is maybe verbose. On the other hand non-keyword notations risk to be too cryptic: some candidates: stuff = groupby((x for x in seq), key = (x.score\x)) # this would require the lexer to distinguish \ as line continuation vs this usage, # it would probably still be read as "x.score given x" stuff = groupby((x for x in seq), key = (x-->x.score)) # --> would be a single token
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4