Asked By – rectangletangle
I have a very long if statement in Python. What is the best way to break it up into several lines? By best I mean most readable/common.
Now we will see solution for issue: Very Long If Statement in Python [duplicate]
According to PEP8, long lines should be placed in parentheses. When using parentheses, the lines can be broken up without using backslashes. You should also try to put the line break after boolean operators.
Further to this, if you’re using a code style check such as pycodestyle, the next logical line needs to have different indentation to your code block.
if (abcdefghijklmnopqrstuvwxyz > some_other_long_identifier and here_is_another_long_identifier != and_finally_another_long_name): # ... your code here ... pass