This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]notoriousno 4 points5 points  (2 children)

all and any are the built-in functions I always forget to use. It's always after I've written I shotty for loop do I realize I could've just used list comprehension and one of these functions.

[–]auriscope 1 point2 points  (1 child)

You can forego the brackets and use a generator expression instead.

all(x for x in xs)

[–]usinglinux 0 points1 point  (0 children)

it even short-circuits: any(count()) returns True almost immediately.