Python Coding specification

Source: Internet
Author: User

First, naming rules

1. Variable names, package names, module names are usually lowercase, or you can use underscores

2. The class name is capitalized and the object name is lowercase. Private variable of class, private method prefixed with two underscore

Example: Class Student: #类名

Student = Student ("ddd") #对象

3. Function names are usually lowercase

Example: Def comparenum (NUM1,NUM2)
Two, code indentation and colon

Code indentation means the hierarchical relationship between each line of code by entering spaces and tabs before each line of code. Code indentation and colons are used to differentiate between the levels of code.

Example: If there is an error in code indentation, Tip: indentationerror:expected an indented block

Third, module import

Module Import with Import

Example: Import sys

Iv. code Comments using #

Support for Chinese annotations, usually preceded by #-*-cpdomg:utf-8-*-

V. Separation of statements

1. You can separate the statements with semicolons or by wrapping them directly

2.Python support multiple lines write a statement

Example: sql = "Select Id,name" \

"From dept" \

"WHERE name = ' A '"

Python Coding 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.