CHAPTER 4
Introducing Python Objects
This chapter begins our tour of the Python language. In an informal sense, in Python we do things with
stuff. “Things” take the form of operations like addition and concatenation, and “stuff ” refers to the
objects on which we perform those operations. In this part of the book, our focus is on that stuff, and
the things our programs can do with it.
Somewhat more formally, in Python, data takes the form of objects—either built-in objects that Python
provides, such as strings and lists, or add-on objects we create with Python classes or external-language
tools. As you’ll find, these objects are essentially just pieces of memory, with values and associated oper‐
ations. Moreover, everything is an object in a Python script. Even simple numbers qualify, with values
(e.g., 99) and supported operations (+, -, and so on).
Because objects are also the most fundamental notion in Python programming, this chapter gets us
started with a survey that previews Python’s built-in object types. Later chapters in this part provide a
second pass that fills in details we’ll gloss over in this survey. Here, our goal is a brief tour to introduce
the basics.
The Python Conceptual Hierarchy
Before we get to the code, let’s first establish a clear picture of how this chapter fits into the overall
Python picture. From a more concrete perspective, Python programs can be decomposed into modules,
statements, expressions, and objects, as follows:
1. Programs are composed of modules.
2. Modules contain statements.
3. Statements contain expressions.
4. Expressions create and process objects.
The discussion of modules in Chapter 3 introduced the highest level of this hierarchy. This part’s chap‐
ters begin at the bottom—exploring both built-in objects and the expressions you can code to use them.
We’ll move on to statements in the next part of the book, though you will find that they largely exist to
manage the objects you’ll meet here. Furthermore, by the time we reach classes in the OOP part of this
book, you’ll discover that they allow you to define new object types of your own, by both using and
The Python Conceptual Hierarchy | 53