samedi 18 avril 2015

Is it ever okay to format any part of the contents of an 'if' statement on the same line as the if statement itself?

I'm doing some practice exercises for beginner Python, and I'm trying to nail down correct formatting, how to make your code clean and fast, and other stuff like that.


One thing I'm unsure of is if statements.


Here's how I usually do if statements:



if something:
do (something)


But I've seen people do this:



if something: do (something)


I've even seen this:



if something: do (something)
then do (something else)


I've also seen people do it with nested if statements, where each and every if/elif/else had the first line of code on the same line as the if/elif/else themselves.


Is it ever okay / proper form to do any of these other methods?


Aucun commentaire:

Enregistrer un commentaire