DEV Community

Discussion on: Are one liners always pythonic?

Collapse
 
miguelmj profile image
MiguelMJ

That's more or less my criteria too.
Out of curiosity, have other people read the one-liners you thought were obvious, but had to take their time to understand them?
In my case, not many people see my code 😅 so I'm not sure if that's the same for everyone. In the end, the level of experience could make vary what is obvious and what no.

Collapse
 
evanroggenkamp profile image
Evan Roggenkamp

The only people I’ve found who find one liners hard to navigate are people who aren’t already familiar with comprehensions. Which is always a fun thing to teach.

Collapse
 
chrisgreening profile image
Chris Greening

I've kind of gotten a feel for what makes sense and what doesn't and this translates to readability for others as well. If the one-liner is longer than 79 characters that's usually a red flag and I always break my statements up as much as possible before introducing a complicated one liner. They usually end up reading more like pseudo code than anything too wild

I will admit I've gotten lazy though and written crazy one liners for throwaway programs or programs under time constraint and will return months later and have trouble reading my own code lol

Thread Thread
 
miguelmj profile image
MiguelMJ

That's one useful link!