Skip to content

Python fast list comprehension

Here’s a one line list comprehension that stops processing the list as soon as it finds a true member, and returns false if all members are false. Keep in mind that you could also use a lamba function to check for a more complex circumstance in the list.


mustBlock = next((True for rule in rules if rule.block == True), False)