Summarize the concept explored in this chapter regarding objects in Python.

We'll cover the following


Some key points in this chapter:

  • Python has optional type hints to help describe how data objects are related and the parameters for methods and functions.
  • We create Python classes with the class statement. We should initialize the attributes in the special __init__() method.
  • Modules and packages are used as higher-level groupings of classes.
  • We need to plan out the organization of module content. While the general advice is “flat is better than nested,” there are a few cases where it can be helpful to have nested packages.
  • Python has no notion of private data. We can see the source code and private declarations aren’t very helpful. This doesn’t change our design; it simply removes the need for a handful of keywords.
  • We can install third-party packages using PIP tools. For example, we can create a virtual environment with venv.


In this chapter, we learned how simple it is to create classes and assign properties and methods in Python. Unlike many languages, Python differentiates between a constructor and an initializer. It has a relaxed attitude toward access control. There are many different levels of scope, including packages, modules, classes, and functions. We understood the difference between relative and absolute imports, and how to manage third-party packages that don’t come with Python.

Get hands-on with 1200+ tech skills courses.