mardi 3 février 2015

Correct way to treat if else with no else to do

Suppose I have an if clause to do something if condition == True and nothing if it's False. What would be the right way to put it? Like this:



beginning of code
if condition == True:
do something
else:
rest of the code


or should I omit the else statement like this:



beginning of code
if condition == True:
do something
rest of the code


or maybe even like this:



beginning of code
if condition == True:
do something
else:
pass
rest of the code


The second one is surely shorter, but other than length of code is there a preferred way to do this?


Aucun commentaire:

Enregistrer un commentaire