Reputation:
I have to check 34 variables in an if
statement (given my problem, I have no other choice).
Is there any PEP that advises on how to write the if
statement in this case ? To be more precise, this is how my code looks like:if((var1==stuff1)and(var2==stuff2)and ...)
I am asking this question for the readability of my code.
Upvotes: 1
Views: 64
Reputation: 363627
There's no PEP saying how code should look except for PEP8. In this case, you can make two tuples variables
and stuff
and compare them with
variables == stuff
Or, if you need to preserve laziness, make two iterables for the variables and the "stuff" and compare with
all(x == y for x, y in zip(variables, stuff))
Upvotes: 1