> I’d say that using lambda expressions is acceptable only if your situation meets all four of these criteria: > 1. The operation you’re doing is trivial: the function doesn’t deserve a name Sure. > 2. Having a lambda expression makes your code more understandable than the function names you can think of This is just vague. Locally defining a function right where you need it makes code much more understandable to me…
Also, wouldn't the existence of a library function (#3) imply that what you're doing is either non-trivial or common enough that someone has already given the function a name? Seems like #1 is sufficient.
import operator
sort(values, key=operator.itemgetter(2))
but it seems decidedly trivial and common to use a lambda: sort(values, key=lambda x: x[2])