Reputation: 12903
What's the most elegant way of doing something like this:
>>> tests = [false, false, false]
>>> map_or(test)
false
>>> tests = [true, false, false]
>>> map_or(test)
true
The map_or
function should return true if one or more of list elements are true.
Upvotes: 2
Views: 701
Reputation: 602035
Use any()
. It is a built-in function that just does what you want.
Upvotes: 9
Reputation: 57514
any(tests)
(and the rest of this is padding because yet again StackOverflow treats users like idiots and sets minimum answer lengths)
Upvotes: 4