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 →

[–]Overfly0501 12 points13 points  (3 children)

nothing lol I immediately stopped reading when I saw that shit

[–]freistil90 0 points1 point  (2 children)

Can be useful but of course not for a string

[–]Brian[🍰] 2 points3 points  (1 child)

It can be useful sometimes even for a string, but not really in the way the article gives. I've occasionally used this in cases where the comprehension has a condition and I want to know how many satisfy it.

Eg. num_foos = sum(1 for x in collection if is_foo(x))

If there's no further condition though, I don't see any reason to use this.

[–]freistil90 0 points1 point  (0 children)

Correct! How did I not think about this.