PYTHON_PEP8 FAQ Record

Source: Internet
Author: User

1. Do not reference multiple libraries in the same sentence import

# Correct posture: Import OS Import SYS # Wrong Posture Import Os,sys

2. Code length constraints

Number of rows: PEP8 Specify a maximum of 79 columns, if the stitching URL is very easy to limit a function: can not exceed 30 lines; Visually speaking is full display a function a screen is enough, do not need to drag a class up and down: do not exceed 200 lines of code, not more than 10 methods a module: not more than 500 lines

3. Common formatting problems

1) W292 no newline at end of file processing: Add a line to the end of the code to enter the line2) E302 expected 2 blank Lines,found 1processing: Need to fill a blank line (the function requires a minimum of 2 blank lines, easy to access, distinguish)3E231 missing whitespace after ', ' processing: The reason is simply to be convenient to view, that is, after the comma "," need to fill the space example:Print("%s %s%s%s"% (a,b,c,d))Print("%s %s%s%s"%(A, B, C, D) may not be very obvious here, but when it comes to modern yards, you will find that the appropriate spaces will appear to be easy to see code .4E225 missing whitespace around operator treatment: the main reason is actually with the above problem three similar, the main purpose is to check the convenience5W291 trailing whitespace processing: a literal meaning, a function, or an example of an extra space appearing at the end of a code segmentreturnKW (there are a few more spaces, errors)returnkw

6) Other
1 typo found # 1 errors found
1 Weak warning found # 1 weak warning

PYTHON_PEP8 FAQ Record

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.