Classes & OOP

Classes & OOP (Python, university-level)

Notebook (download/open locally): /kicsigeze/notebooks/01_classes_oop.ipynb

What you should get out of this

  • Design classes with invariants and clean APIs
  • Understand attribute lookup, __getattribute__, and the descriptor mechanism at a practical level
  • Use dataclasses and typing to make code more correct and readable
  • Implement iteration, context managers, and rich comparisons the Pythonic way

Suggested workflow

  1. Open the notebook in JupyterLab/VS Code.
  2. Run the “warm-up” cells quickly.
  3. Spend most of your time on the Exercises.

Exercises (quick list)

  • Implement a Vector type with normalization + rich comparisons
  • Implement a small LRUCache using __getitem__ / __setitem__
  • Write a context manager that measures elapsed time and logs it

Readings/videos: Reading / Videos