3 ms·
The argument used by the author for 'abs' and 'min' can also be useful for all of the functions in the operator module: https://docs.python.org/3/library/opera
by michelpp 8y ago
The argument used by the author for 'abs' and 'min' can also be useful for all of the functions in the operator module:
https://docs.python.org/3/library/operator.html https://docs.python.org/3/library/operator.html
In particular 'attrgettr' and 'itemgettr' are very useful functions to map over objects and sequences.
- mlevental 8y agooh nice I've been using itemgetter for sorted and things for a long time. didn't realize (but should have) there was attrgetter to match. will definitely come in handy
- Too 8y agoIs attrgetter recognized by static code checkers like mypy and pycharm? One of the benefits of lambdas is that arguments autocomplete even without manual type annotations.