This repo is a test-driven koans style course for Python fluency: you run tests, they fail with a message, you implement small bits of code, and repeat.
This project is inspired by the kinds of topics commonly covered in advanced Python books (data model, functions, iterators, context managers, concurrency, typing), but all code and explanations here are original.
- Python 3.11+ recommended (works on 3.10+ if you adjust a few type hints).
Run the koans:
python3 -m unittest -qRun a specific file:
python3 -m unittest -q tests.test_01_data_model- Tests live in
tests/. - Your implementations live in
koans/answers/. - Each koan is a small concept. Read the failure message, then implement the requested behavior.
- Data model / dunder methods (
__repr__,__iter__,__len__, etc.) - Sequences and slicing
- Dictionaries, sets, and mappings
- Functions as objects; closures
- Decorators (simple + parameterized)
- Iterators, generators,
yield from - Context managers
dataclassesand composition- Protocols / structural typing (lightweight)
- Properties and validation
- Attribute access (
__getattr__) - Concurrency (threads/asyncio basics)
MIT. See LICENSE.