#from "Python 2.7.9 Documentation"
-
Use 4-space indentation, and No tabs.
- #使用4空格缩进, do not use the tab indent
-
Wrap lines so they don ' t exceed characters.
- Split lines to ensure that no more than 79 characters per line
-
Use blank lines to separate functions and classes, and larger blocks of code inside functions.
- The function and the class are separated by a blank line, including chunks of code that are separated by a blank line
-
When possible, put comments on a line of their own.
- Note a single row
-
Use Docstrings.
- Working with document Strings
-
Use spaces around operators and after commas, but not directly inside bracketing constructs: a = f (1, 2) c5>+ g (3, 4).
- Left and right side of operator, but no space in brackets: a = f (1, 2) + g (3, 4)
-
Name your classes and functions consistently; The Convention is to use CamelCase for classes and Lower_case_with_underscores for functions and methods . Always use self as the name of the first method argument (see A First look at Classes for more on C Lasses and methods).
- Uniform class name and function name, recommended class name with hump name: SampleClass, function name with lowercase and underscore name: Get_page (), try to use self as the first parameter of the method
-
Don ' t use fancy encodings If your code are meant to being used in international environments. Plain ASCII works best in any case.
- Use code sparingly in an internationalized environment, with the best ASCII. (in Chinese environment, recommended Utf-8)
Python Coding Style/python Programming style