Python recommends the maximum number of characters per line

anonymity
Release: 2019-06-12 11:30:32
Original
5640 people have browsed it

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.

Python recommends the maximum number of characters per line

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!