Style guide conformists: why not one line if statements?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By CalmTurtle

I can completely understand why, with more than one line inside the if statement, it makes sense to put them on sequential lines. But with a one liner, it looks and reads better. Please help me understand, so I can buy into this uglier formatted code:

# Pretty
if my_bool: do_one_thing()

vs

 # !Pretty
 if my_bool:
        do_one_thing()
:bust_in_silhouette: Reply From: kidscancode

“Looks and reads better” is purely your opinion, others will disagree. Personally, I find it less readable because now there are two statements on one line, and two different ways to read an if.

If you’re happy with it in your code, feel free, nobody is going to mind. However, the style guide is designed for wide usage and consistency. There’s no need for a different rule for one-line versus multi-line conditionals.

Thank you for the take.

CalmTurtle | 2019-04-04 22:42