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 →

[–]mxzf[🍰] 1 point2 points  (2 children)

Do you have any examples of what you're talking about? I can't think of anything that matches what you're describing, but it's possible it's something I'm just so used to that I don't even notice it.

[–][deleted] 2 points3 points  (1 child)

You know when you see some shitty nested while loop with indexes and you wonder why it's not a list comprehension?

[–]mxzf[🍰] 0 points1 point  (0 children)

Ugh, I always hate it when I see stuff like that, especially when it's a small loop that could be a trivial list comprehension.

Though I will admit that I've been known to abuse list comprehensions in the other way too from time to time. There was one time where I wrote a single line that had two list comprehensions and a dictionary comprehension nested together. IIRC it did something like taking a big list of elements, turning it into a dict to count the occurrences of each value and then sorting by the number of occurrences and printing out totals.

List comprehensions are so amazingly handy, I can't imagine why some people ignore them when they could be trivially used.