3 ms·
While I do know about those and they are indeed much more pythonic and cleaner, I often end up just using `lambda x: x[1]` instead of `import operator; operator
by ehsankia 5y ago
While I do know about those and they are indeed much more pythonic and cleaner, I often end up just using `lambda x: x[1]` instead of `import operator; operator.itemgetter(1)`. For sort, I'll also often do `sorted(mydict, key=mydict.get)` which is again not the most pythonic.
I just wish there were nicer ways to do these in the global namespace, but poluting builtins is probably not a great idea either. Maybe `slice.itemgetter` or `object.attrgetter`.