Hello
any() and all() are very useful small functions, and I am wondering
if it could be interesting to have them work
with different operators, by using a callable.
e.g. something like:
import operator
def any(iterable, filter=operator.truth):
for element in iterable:
if filter(element):
return True
return False
For instance I could then us any() to find out if there's a None in
the sequence:
if any(iterable, op=lambda x: x is None):
raise SomeError("There's a none in that list")
Granted, it's easy to do it myself in a small util function - but
since any() and all() are in Python...
Cheers
Tarek
--
Tarek Ziadé · http://ziade.org · @tarek_ziade