[Python-ideas] Adding an optional function argument to all() and any() builtins
Steven D'Aprano
steve at pearwood.info
Mon Nov 22 05:29:12 CET 2010
Raymond Hettinger wrote:
> On Nov 21, 2010, at 5:57 PM, Bruce Frederiksen wrote:
>
>> There have been several times when I wished that any/all acted like or/and because I needed the offending value for further use...
>
> This is such a trivial function.
> Why not just roll your own and dump it in your personal utils?
In fairness, the same could be said about any() and all() in the first
place. The advantages are that the built-ins are significantly faster
than the pure-Python version (a factor of 3 times faster on my machine
using Python 3.1), and they're available everywhere you go, without
re-writing the functions or importing them.
I'm (mildly) with Bruce on this one, but I think we missed the boat.
Perhaps in Python4000 any() and all() should return the relevant object
rather than True/False.
--
Steven
More information about the Python-ideas
mailing list