Python style: multiple-line conditions in IFs
- by Eli Bendersky
Hello,
Sometimes I break long conditions in IFs to several lines. The most obvious way to do this is:
if (cond1 == 'val1' and cond2 == 'val2' and
cond3 == 'val3' and cond4 == 'val4'):
do_something
Isn't very very appealing visually, because the action blends with the conditions. However, it is the natural way using correct Python indentation of 4 spaces.
Edit:
By the way, for the moment I'm using:
if ( cond1 == 'val1' and cond2 == 'val2' and
cond3 == 'val3' and cond4 == 'val4'):
do_something
Not very pretty, I know :-)
Can you recommend an alternative way ?