Python Code Authoring specification

Source: Internet
Author: User

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

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.