DEV Community

Discussion on: 18 Python one-liners that will speed up your coding process.

Collapse
 
cappe987 profile image
Casper

Others have already pointed out that a lot of these are bad ideas, I would like to add one thing. While ternary if's, list comprehension and lambdas are cool, they are not equivalent to their regular variants. Once you have an if-statement with two statements inside it you can no longer convert it into a ternary. Same applies to list comprehension and lambdas. They are all basically simpler and more restricted versions of the regular variants, and have a more specific use-case. If you do not know when to use them it is better to avoid them rather than trying to squeeze them in wherever possible.