DEV Community

Discussion on: Are one liners always pythonic?

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

One-liner is a joke. Isn't minified Javascript also a one liner?

Python can also force one liner using semicolon. (And also break new line using back slash, IIRC.)

That aside, readability is the most important, and after that, performance.

Make mutable variables and loops if you have to. You don't need generator expressions every time, and it might confuse you.

Also, named functions might be preferable to lambdas in any programming languages. It will make testing easier.

Collapse
 
miguelmj profile image
MiguelMJ

I think that with semicolons doesn't count as one liner. Also, sometimes on liners improve readability.
However, I think you're right about not having to use always generators. Just because you can doesn't mean that you should!