dimanche 7 avril 2019

Using tuples of bools for if statements

I would like to know if it is a good practice to use tuples instead of separated expressions in a if statement.

is_dog = True
is_cat = False

I would like to do like this:

if (is_dog, is_cat):
    do_something()

Instead of like this:

if is_dog or is_cat:
    do_something()

What is the best practice in this case? Thank you

Aucun commentaire:

Enregistrer un commentaire