Section 6: Modules, Packages and Project Structure
- import, packages and the src layout
- if __name__ == "__main__" and entry points
- Explicit lazy imports in Python 3.15 to cut start-up time
- Lab: split the StockSense code into modules by responsibility
Section 7: Type Hints and Type Checking
- Type hints for variables, functions and collections
- Union, Optional, Literal, TypedDict and Protocol
- Check with mypy or Pyright and read the results
- Lab: add type hints to existing code and fix what the type checker reports
Section 8: Object-Oriented Programming the Python Way
- Classes, __init__, instance and class attributes, and methods
- Inheritance, composition and dunder methods (__repr__, __eq__)
- @property, @classmethod and @staticmethod
- Differences from OOP in Java and C# that learners should know
Section 9: dataclasses and Enum
- @dataclass with frozen, field and __post_init__ for validation
- Enum for fixed sets of values, such as categories and stock movement types
- Comparing dataclasses with NamedTuple and dict
- Lab: design the Product and StockMovement models
Section 10: Workshop: Files, Data and Error Handling
- pathlib, reading and writing files, and UTF-8 as the default in Python 3.15
- Reading and writing CSV and JSON
- try, except, else, finally, custom exceptions and exception chaining
- Context managers with with, and writing your own with contextlib
- Workshop: import products from CSV, export a JSON report and handle malformed data