Python Code Authoring specification
Coding:
A) If no special circumstances apply, the document is UTF-8 encoded
b) If no special circumstances are required, the file head must be added to #-*-coding:utf-8-*-
Indent in
A) uniformly use 4 spaces for indentation
Quotes
A) Natural language using double quotes "...", regular expressions using native double quotes R ""
b) machine identification using single quote "'
c) The document string (docstring) uses three double quotes "" "..." "
Blank Line
A) empty two lines between module-level functions and class definitions
b) An empty line between class member functions
Import statement
A) Import statements should be ordered in order, separated by a blank line between each group
Binary operators
A) The two-dollar operator is empty on either side of the grid, =-
parameter list of the function
A) in the argument list of the function, ', ' after the comma, there will be a space
b) in the parameter list of the function, do not add a space on either side of the default equals sign
c) After the opening parenthesis, do not add extra space before the closing parenthesis
D) do not leave extra spaces before the opening parenthesis of the Dictionary object
Line break
A) The second line indents to the beginning of the parentheses
b) The second line indents 4 spaces, applies to the case where the starting parenthesis wraps
DocString
A) All public modules, functions, classes, methods, should be written docstring, private methods are not necessarily required, but should be provided after def a block of comments to explain "" "" ""
Comments
A) a meaningful comment list #list
b) More important annotation segments, separated by multiple equal signs, can be more eye-catching, highlighting the importance
Naming conventions
A) module name as far as possible use lowercase name, the first letter keep lowercase, try not to underline (unless multiple words, and a small number of cases
b) class name using Hump (CamelCase) naming style, capitalize first letter
c) The function name is lowercase, if there are multiple words, separated by underscores
d) Variable names as small as possible, with multiple words, separated by underscores
e) Constants in full capitalization, if there are multiple words, separated by underscores
Python Code Authoring specification