Chapter 2. Types and Operators

This chapter begins our tour of the Python language. From an abstract perspective, in Python we write programs that do things with stuff.[8] Programs take the form of statements, which we’ll meet later. Here, we’re interested in the stuff our programs do things to. And in Python, stuff always takes the form of objects. They may be built-in kinds of objects Python provides for us, or objects we create using Python or C tools. Either way, we’re always doing things to objects in Python.

Naturally, there’s more to Python development than doing things to stuff. But since the subjects of Python programs are the most fundamental notion in Python programming, we start with a survey of Python’s built-in object types.

Python Program Structure

By way of introduction, let’s first get a clear picture of how what we study in this chapter fits into the overall Python picture. From a more concrete perspective, Python programs can be decomposed into modules, statements, and objects, as follows:

  1. Programs are composed of modules.

  2. Modules contain statements.

  3. Statements create and process objects.

[8] Pardon our formality: we’re computer scientists.

Get Learning Python now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.