Simple and compound statements

https://docs.python.org/3/reference/lexical_analysis.html

https://stackoverflow.com/questions/2998215/if-python-is-interpreted-what-are-pyc-files/2998544

INTRODUCTION

The simplest control flow: a sequential execution of statements.


statement1
statement2
statement3
...

LEXICAL ANALYSIS

A Python program is divided into a number of logical lines. A Python program is read by a parser. Input to the parser is a stream of tokens, generated by the lexical analyzer.


Python 3 source code
|
| (Unicode code points)
o
Lexical analyzer
|
| (a stream of tokens)
o
Parser [SyntaxError possible]
|
|
o
Compiler [differences for CPython, IronPython, Jython, ...]
|
| (bytecode) [.pyc files for modules]
o
Python Virtual Machine (interpreter) [CPython VM, .Net runtime (CLR), Java VM]
|
| (machine code)
o
Executing on CPU [runtime exceptions possible]

SIMPLE STATEMENTS

https://docs.python.org/3/reference/simple_stmts.html

A simple statement is comprised within a single logical line. Several simple statements may occur on a single line separated by semicolons.

Examples: expression, assignment, assert, pass, del, return, yield, raise, break, continue, import, global, nonlocal.

COMPOUND STATEMENTS

https://docs.python.org/3/reference/compound_stmts.html

Compound statements contain other statements. In general, compound statements span multiple lines, although in simple incarnations a whole compound statement may be contained in one line.

Examples: if, while, for, try, with, def, class.