PySR 0008: Line Length¶
Abstract¶
You should avoid overly-long lines, as they make the code harder to read and understand, especially on small screens.
Line Lengths¶
All lines should be limited to a maximum of 100 characters.
Docstrings and comments should be limited to 70 characters, where appropriate.
Code snippets in public documentation should preferably be kept to 70-90 characters at most.
Splitting Lines¶
Function call splitting¶
When splitting a function, place the function name and opening parantheses on the first line, the arguments on the following lines — one per line — indented by another level, with the closing parantheses placed on the last line, after all arguments, indented as much as the line from which the function call started.
While not recommended, one or more arguments can be placed on the same line as the opening parantheses, after the opening parantheses, with no extra space between.
Arithmetic splitting¶
When splitting arithmetic, either:
- Split the line, placing a backslash (
\) at the end of the first line, and start the second line with the arithmetic operator - Wrap the entire arithmetic expression in parantheses (
()), with new lines after the opening parantheses and before the closing parantheses, and with all inner lines indented by another level, and start the second line with the arithmetic operator
The arithmetic operator at the start of the next line should be indented as much as the first item of the arithmetic expression.
Comment splitting¶
If a comment needs to be split across multiple lines, move the comment onto its own line (if not already on its own line), and create a new comment on the following line for the rest of the text. Repeat this as needed. Make sure that, before all the comments, there is a new line, if there is any code before them.
Split multi-line comments like these up into blocks/paragraphs, separated by empty comments in between, when they get too long.