Section 6: Lab: Inheritance and the MRO
- Inherit from a class and call the parent with super()
- Override methods with the @override decorator from typing
- Multiple inheritance and the method resolution order (MRO)
- Mixins that add small capabilities to several classes
- Lab: regular customers and members with different discounts
Section 7: Polymorphism and Duck Typing
- What polymorphism is and calling the same method on different objects
- Duck typing, the idea Python uses instead of enforcing types
- Operator overloading with __add__ and related methods
- Dispatch by type with singledispatchmethod and match
- Lab: several payment channels used through one piece of code
Section 8: Lab: Abstract Classes and Protocols
- Abstract classes with the abc module, ABC and @abstractmethod
- The difference between ordinary classes and abstract classes
- Python-style interfaces with typing.Protocol
- Runtime checks with @runtime_checkable and their limits
- Lab: define the contract for a delivery system and write several implementations
Section 9: Composition and the SOLID Principles
- Composition over inheritance and signs of too much inheritance
- Single responsibility and open/closed
- Liskov substitution, interface segregation and dependency inversion
- Pass dependencies through the constructor to make testing easy
- Workshop: change the shipping cost system to add new rules without editing existing code
Section 10: Lab: Type Hints for Object-Oriented Code
- The new generic class syntax, such as class Repository[T], and the type statement
- Self, ClassVar, Final and Enum for constants
- Deferred evaluation of annotations in Python 3.14
- Check the whole project with mypy and read its warnings
- Lab: a generic repository for products and customers