On Feb 3, 2006, at 1:36 AM, Michael Hudson wrote: > Alex Martelli <aleaxit at gmail.com> writes: > >> I was recently reviewing a lot of the Python 2.4 code I have written, >> and I've noticed one thing: thanks to the attrgetter and itemgetter >> functions in module operator, I've been using (or been tempted to >> use) >> far fewer lambdas, particularly but not exclusively in key= arguments >> to sort and sorted. > > Interesting. Something I'd noticed was that *until* the key= argument > to sort appeared, I was hardly using any lambdas at all (most of the > places I had used them were rendered obsolete by list comprehensions). Mine too, but many new places appeared, especially in itertools. > A class I wrote (and lost) ages ago was a "placeholder" class, so if > 'X' was an instance of this class, "X + 1" was roughly equivalent to > "lambda x:x+1" and "X.method(zip, zop)" was roughly equivalent to your > "methodcaller("method", zip, zop)". I threw it away when listcomps > got implemented. Not sure why I mention it now, something about your > post made me think of it... Such a placeholder would certainly offer better syntax and more power than methodcaller (and itemgetter and attrgetter, too). A lovely idea! Alex
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