I really don't see the benefit.
I really don't see the benefit.
if not all(is_valid, the_values):
inform_user("You supplied bad data")
Or perhaps bad_values = select(is_not_valid, the_values)
if some(bad_values):
inform_user("The following values were bad", bad_values)
Yes, sometimes you might want to do several things in a single iteration for reasons of efficiency, but in that case you can compose() the functions representing the per-element operations.This code is only "cryptic" to people not used to functional programming. If the intended audience is the set of everyone who knows Python, using these abstractions will reduce the number of people who understand the code. If it's your startup's team of three programmers, there's a good chance the time saved is worth the learning curve.
And you won't while you just pass it off as something that "just makes your code compact."
Regarding your comment about comments -> imagine a world where there were no for loops, then somebody invents a for loop. What would you say to the person who shoots it down because it just "makes code compact" and programmers don't want to have to add a comment above a cryptic 'for loop' explaining what it does?