I've used one or two of these before, would be interested in more patterns that use, methodcaller (I think in the example given str.strip would have worked too).
That is, sometimes when I'm making a largeish modification there's a point in the commit series where the natural way to express what's going on involves using methodcaller, then by the time the work is finished the use has gone away again.
close_file = methodcaller('close')
exhaust(map(close_file, files))
where exhaust is a function that consumes an iterator. Obviously this is a contrived example, but it's a weird transformation -- it turns map from 'call this function on each of a sequence of arguments' to, roughly 'call each of this sequence of functions on a fixed argument'Both by a compiler easily readable by a human unreadable out of purely functional languages by design this high fashion came.
Do you think it's better to use a conceptually difficult example to showcase a high order function? Or do you think it's better to show an example where the reader can accurately understand the concept and focus on what the function does?