July 2009
Intermediate to advanced
744 pages
20h 2m
English
This chapter covers the details of program structure and control flow. Topics include conditionals, iteration, exceptions, and context managers.
Python programs are structured as a sequence of statements. All language features, including variable assignment, function definitions, classes, and module imports, are statements that have equal status with all other statements. In fact, there are no “special” statements, and every statement can be placed anywhere in a program. For example, this code defines two different versions of a function:

When loading source files, the interpreter ...
Read now
Unlock full access