6
Objects & Classes
You have used objects since Day 1 — every string is one. Today you build your own types, teach them how to print and compare, and let them share code.
Lessons
- 1 Classes & Objects Define your own types: __init__, attributes, methods, and the difference between a class and an instance. classes objects oop
- 2 Dunder Methods Teach your objects to print, compare, add, and work with len() — by implementing the methods Python already looks for. dunder operators protocols
- 3 Inheritance & Composition Share behaviour between classes — and learn why 'has a' usually beats 'is a'. inheritance composition polymorphism
- 4 Dataclasses & Type Hints Let Python write the boilerplate, and annotate your code so tools and readers know what goes where. dataclasses type-hints properties