Next / Previous / Contents / TCC Help System / NM Tech homepage


A quick reference for the Python programming language, version 2.2.

This publication is available in Web form and also as a PDF document. Please forward any comments to

Table of Contents

1. What is Python?
2. Starting Python
3. Line syntax
4. Reserved words
5. Basic types
6. Numeric types
6.1. Integers: int and long types
6.2. The float type
6.3. The complex type
6.4. Intrinsics for numbers
7. The sequence types
7.1. Intrinsic functions common to all sequences
7.2. Strings: the str and unicode types
7.3. The list type
7.4. The tuple type
8. The dictionary type
8.1. Operations on dictionaries
9. Input and output: File objects
10. Expressions
10.1. What is a predicate?
11. Built-in functions for multiple types
12. Python statements
13. Simple statements
13.1. Assignment
13.2. The assert statement
13.3. The del statement
13.4. The exec statement
13.5. The from statement
13.6. The global statement
13.7. The import statement
13.8. The pass statement
13.9. The print statement
14. Compound statements
14.1. Boolean values: true and false
14.2. The if construct: choice
14.3. The for construct: iteration
14.4. The while construct: looping
14.5. The break statement
14.6. The continue statement
14.7. The try construct: catching exceptions
14.8. The raise statement: throwing exceptions
15. Exceptions
16. Defining and calling functions
16.1. Calling a function
16.2. return: Return the result of a function
17. Create your own types: The class construct
17.1. __init__(): The class constructor
17.2. Special method names
17.3. Intrinsics for objects
18. Recent features
18.1. Iterators
18.2. Generators
18.3. Static methods
18.4. Class methods
19. The Python debugger
19.1. Starting up pdb
19.2. Functions exported by pdb
19.3. Commands available in pdb
20. Commonly used modules
20.1. The math module
20.2. The cmath module: complex math
20.3. The types module
20.4. The string module
20.5. Regular expression matching with the re module
20.6. The sys module
20.7. The random module: random number generation
20.8. The time module: dates and times
20.9. The os module: operating system interface
20.10. The stat module: file statistics
20.11. The path module: file and directory interface
20.12. Low-level file functions in the os module

1. What is Python?

Python is a recent, general-purpose, high-level programming language. It is freely available and runs pretty much everywhere.