Python's coding style is described by PEP 8 . This document describes various aspects of Python programming style. As long as this document is adhered to, Python code written by different programmers can maintain a similar style to the greatest extent possible. This makes it easy to read and communicate between programmers.
Code layout style
Indentation. Prioritize the use of 4-space indentation (any editor can complete this function), followed by Tap, but never mix Tap and spaces.
The maximum length of each line is 79. You can use backslashes for line breaks. It is best to use parentheses. The line break point must be hit after the operator.
Two blank lines between class and top-level function definitions; one blank line between method definitions in classes; one blank line between logically irrelevant paragraphs within functions; try not to use blank lines elsewhere.
One function: no more than 30 lines of code, it can be displayed on a screen class, and the entire function can be seen without using the vertical cursor; one class: no more than 200 lines of code, no more than 10 methods ;A module should not exceed 500 lines.
Python PEP8 recommends that a line should not exceed 79 characters, but what should I do if I have a string that is very long?
There is a string that is very long. Long, you can use backslash (\) to break the line
The above is the detailed content of Python recommends the maximum number of characters per line. For more information, please follow other related articles on the PHP Chinese website!