Skip to main content
Submitted by admin on 9 January 2022

1. Indentation:

The recommendation is to use 4 spaces for indentation.


Blank Lines


In Python scripts, top-level function and classes are separated by two blank lines. 
Method definitions inside classes should be separated by one blank line.

Whitespaces

  • should try to avoid whitespaces in Expressions and Statements.
  • Add blank line before a single line comment
  • Break up sections of code with white space.

Imports

 each import should be on a single line.

 

Source File Encoding

 Python 3 has UTF-8 ,the default source encoding. 

 

2. naming conventions

Variables naming conventions

Use snake_case And All Lower Case

snake case: when words are separated by underscores.

Example: lower_case_with_underscores.

 

Classes naming conventions

use CamelCase for class definitions.


CamelCase: first letter capitalized With Every word.

Example: CapitalizedWords.

 

3.General conventions

  • Capitalize the first letter of a sentence.
  • Capitalize the first letter of someone’s name.
  • Add a space after the end of a sentence.
  • Add a space after each word.

4. use of comments

5. line lengths

6. use of white space