Source: https://mokxi.com/learn/path/python-oop-in-depth
Updated: 2026-11-20

All paths

# Objects in depth

Object-oriented Python past the basics, on a Raspberry Pi: class and instance attributes, inheritance and super(), composition, dunder methods, properties, dataclasses and enum, ending with a device library for a starship.

Raspberry Pi 4 Model B Free 7 lessons 5 h 4 chapters 2,125 XP Coding · Intermediate +150 XP

0 of 7 done

Start the course free Classes revisited Lesson plan for teachers

What you will build

## 3 projects, built step by step

7 lessons in 4 chapters, about 5 hours on a simulated Raspberry Pi 4 Model B. Free, in your browser, every step checked by the simulator.

Chapter 1 project

### Inheritance

Give the Kestrel's bridge lights a family tree: a Device base class, subclasses that override and extend with super(), one loop that drives any device (polymorphism), and an abstract base class that refuses a subclass missing its methods.
Open it in the simulator

Chapter 2 project

### Dunder methods

Make the Kestrel's lamps act like Python's own types: __repr__ and __str__ for printing, __len__, __getitem__, __contains__ and __iter__ for a container, __lt__ and __bool__ for sorting and truth, __add__, and __enter__ and __exit__ for a with block.
Open it in the simulator

Chapter 3 project

### dataclasses and enum

Let Python write the boring parts: a dataclass in place of hand-written __init__, __repr__ and __eq__, frozen records that cannot be changed by accident, an Enum whose typos fail loudly, and the plain-class constants pattern for boards with no enum module.
Open it in the simulator

The map

## Chapter by chapter

Each lesson opens when the one before it is done, and each chapter ends in a project.

Chapter 1

## Classes and families

What a class really is, and how classes inherit from each other.

Open 205 XP

### Classes revisited

Look again at the class you think you know, on the starship Kestrel's lamps: what self really is, the shared-list bug that class attributes cause, the right use for them, classmethods as second constructors, and bound methods.

0 of 5 steps

Start What is in it

Project Locked 410 XP

### Inheritance

Give the Kestrel's bridge lights a family tree: a Device base class, subclasses that override and extend with super(), one loop that drives any device (polymorphism), and an abstract base class that refuses a subclass missing its methods.

0 of 5 steps

5 questions, graded as you go.

Chapter 2

## Parts and protocols

Objects built from objects, and objects that act like Python's own types.

Locked 174 XP

### Composition

Build the Kestrel's bridge panel out of parts instead of a family tree: a panel that has lamps, modes as data, lamps handed in from outside so a fake can stand in for testing, and a button wired to a bound method.

0 of 4 steps

Project Locked 472 XP

### Dunder methods

Make the Kestrel's lamps act like Python's own types: __repr__ and __str__ for printing, __len__, __getitem__, __contains__ and __iter__ for a container, __lt__ and __bool__ for sorting and truth, __add__, and __enter__ and __exit__ for a with block.

0 of 6 steps

5 questions, graded as you go.

Chapter 3

## Rules and records

Properties that guard the hardware, dataclasses and enums that cut the boilerplate.

Locked 236 XP

### Properties

Guard the Kestrel's cargo hatch servo: see a plain attribute lie about where the hatch is, turn it into a property whose setter moves the servo and clamps bad angles, add a read-only computed property, and refuse moves while the hatch is locked.

0 of 6 steps

Project Locked 410 XP

### dataclasses and enum

Let Python write the boring parts: a dataclass in place of hand-written __init__, __repr__ and __eq__, frozen records that cannot be changed by accident, an Enum whose typos fail loudly, and the plain-class constants pattern for boards with no enum module.

0 of 5 steps

5 questions, graded as you go.

Chapter 4

## Project

A device class library for the starship Kestrel.

Locked 218 XP

### Project: a device class library

Put the course together as a real library: a kestrel.py module with Device, Lamp and Hatch classes, a Ship that composes them, a serial console that drives any device by name, and a new device type added without touching the code that uses it.

0 of 6 steps

4 questions, graded as you go.

Syllabus

## Every lesson in the course

All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.

Chapter 1

### Classes and families

- Classes revisited Look again at the class you think you know, on the starship Kestrel's lamps: what self really is, the shared-list bug that class attributes cause, the right use for them, classmethods as second constructors, and bound methods.
- Inheritance Give the Kestrel's bridge lights a family tree: a Device base class, subclasses that override and extend with super(), one loop that drives any device (polymorphism), and an abstract base class that refuses a subclass missing its methods.

Chapter 2

### Parts and protocols

- Composition Build the Kestrel's bridge panel out of parts instead of a family tree: a panel that has lamps, modes as data, lamps handed in from outside so a fake can stand in for testing, and a button wired to a bound method.
- Dunder methods Make the Kestrel's lamps act like Python's own types: __repr__ and __str__ for printing, __len__, __getitem__, __contains__ and __iter__ for a container, __lt__ and __bool__ for sorting and truth, __add__, and __enter__ and __exit__ for a with block.

Chapter 3

### Rules and records

- Properties Guard the Kestrel's cargo hatch servo: see a plain attribute lie about where the hatch is, turn it into a property whose setter moves the servo and clamps bad angles, add a read-only computed property, and refuse moves while the hatch is locked.
- dataclasses and enum Let Python write the boring parts: a dataclass in place of hand-written __init__, __repr__ and __eq__, frozen records that cannot be changed by accident, an Enum whose typos fail loudly, and the plain-class constants pattern for boards with no enum module.

Chapter 4

### Project

- Project: a device class library Put the course together as a real library: a kestrel.py module with Device, Lamp and Hatch classes, a Ship that composes them, a serial console that drives any device by name, and a new device type added without touching the code that uses it.

Kits

## Build it on your bench too

Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.

Have a kit already?

### Find your kit

Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.
See every kit

Questions

## About Objects in depth

Is Objects in depth free?

Yes. All 7 lessons of Objects in depth are free and run in your browser, with nothing to install and no parts to buy before you start.

Do I need a real Raspberry Pi 4 Model B?

No. Every lesson runs on a simulated Raspberry Pi 4 Model B with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.

How long does Objects in depth take?

About 5 hours: 7 lessons in 4 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.

What will I build?

Each chapter ends in a project that puts it together: Inheritance, Dunder methods and dataclasses and enum.

Where do I start?

With "Classes revisited", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.
