DEV Community

Discussion on: Ditch These 7 Bad Habits in Python

Collapse
 
romansorin profile image
Roman Sorin

List comprehension is one of my favorite tools for writing effective statements and fewer lines, but it needs to be done right. The example is likely slightly exaggerted (the
"fruit for fruit in fruits" bit), but I've seen it done. I believe they are more readable and easier to understand if the names of variables/elements are chosen properly — but we know that naming is the hardest thing :)