Line, Comment
A hash sign (#) that is not inside a string literal begins a comment.
In Python, the end of a physical line marks the end of most statements. Unlike in other languages, you don't normally terminate Python statements with a delimiter, such as a semicolon (;).
When a statement is too long to fit on a single physical line, you can join two adjacent physical lines into a logical line by ensuring that the first physical line has no comment and ends with a backslash (\).
However, Python automatically joins adjacent physical lines into one logical line if an open parenthesis ((), bracket ([), or brace ({) has not yet been closed, and taking advantage of this mechanism, generally produces more readable code instead of explicitly inserting backslashes at physical line ends.
Indention
Python uses indentation to express the block structure of a program. Unlike other languages, Python does not use braces, or other begin/end delimiters, around blocks of statements
The first statement in a source file must have no indentation.
Python logically replaces each tab by up to eight spaces, so that the next character after the tab falls into logical column 9, 17, 25, etc. Don't mix spaces and tabs for indentation.
Character Sets
Normally, a Python source file must be entirely made up of characters from the ASCII set.
However, you may choose to tell Python that in a certain source file you are using a character set that is a superset of ASCII. In this case, Python allows that specific source file to contain characters outside the ASCII set, but only in comments and string literals.
To accomplish this, start your source file with a comment whose form must be as rigid as the following:
# -*- coding: utf-8 -*-
Tokens
Case is significant in Python: lowercase and uppercase letters are distinct.
Normal Python style is to start class names with an uppercase letter and all other identifiers with a lowercase letter.
Starting an identifier with a single leading underscore indicates by convention that the identifier is meant to be private.
Starting an identifier with two leading underscores indicates a strongly private identifier; if the identifier also ends with two trailing underscores, the identifier is a language-defined special name.
The identifier _ is special in interactive interpreter sessions: the interpreter binds _ to the result of the last expression statement it has evaluated interactively, if any.
Statements
Any expression can stand on its own as a simple statement. Unlike in some other languages, an assignment in Python is a statement and can never be part of an expression.
A compound statement has one or more clauses, aligned at the same indentation. Each clause has a header starting with a keyword and ending with a colon (:), followed by a body, which is a sequence of one or more statements. When the body contains multiple statements, these statements should be placed on separate logical lines after the header line, indented four spaces rightward.