Modern Python: From Basics to FastAPI in Production book cover
Book

Modern Python: From Basics to FastAPI in Production

Python 3.14 + uv + Type Hints First — One Book Cover to Cover

In progress 34 chaptersLast updated: May 17, 2026
Start from chapter 1 →

All 34 chapters, including Appendix A, are available to read on the site right now. Start from any chapter — the “Where to start” section below points you to an entry point that fits your background.

What this book covers #

  1. The current Python standard workflow — one tool, uv, unifies environments, packages, and execution in place of pip + venv + pyenv. Everything is organized around pyproject.toml.
  2. Type hints first — every example carries type hints alongside the code. You get the help of mypy / pyright from the start as a default habit.
  3. A connected path from fundamentals to production — variables, FastAPI, SQLAlchemy, JWT auth, and deployment are introduced as parts of one practical service-building flow.
  4. The operational work is included — logging, observability, testing, CI, and library publishing are covered in the later chapters as part of real project work.

What this book does not cover #

  • Domain applications such as data analysis / ML / games / GUI — separate books cover those.
  • A complete tour of the standard library — only the top 30 in the appendix.
  • 2017-style code (Python 2 compatibility, % strings, dict.has_key, etc.) — the old Python Basics tutorial (21 parts) is still up.

Who this book is for #

  • People learning Python for the first time — beginners who want to learn with current tools and syntax. You start on the modern stack from the very beginning.
  • People who know old Python but not the modern workflow — those who learned during the 2.7 ~ 3.5 era and stopped there. The appendix’s migration guide for old code is the entry point.
  • People coming to Python from another language — you can skim Part 1 and absorb the core from Parts 2 ~ 5. The type-hints-first approach lowers the entry barrier.

Where to start #

All 34 chapters are free to read in any order, but if you are not sure where to begin, here are three recommended entry points.

  • Chapter 1: Getting Started and uv Setup — the starting line of the book. Instead of the 2017-era pip + venv, you unify environments, packages, and execution with a single tool, uv. The first chapter most beginners should open.
  • Chapter 2: Variables, Basic Types, and Type Hints — the chapter where you build the “type-hints-first” identity of this book from the very start. The most direct entry point for anyone curious about the modern Python flow.
  • Appendix A: Migrating Old Python Code — a guide to moving Python 2-compatible code, % strings, and pip + venv over to the 3.14 + uv + type-hints style. The chapter where readers coming from old Python get the most value.

Each of these three serves as an entry point in its own right. Open whichever appeals to you first.

The series this book is built from #

This book is built from the four series below (27 parts total) + 7 new chapters + a full revision pass. The source series are still up on the site for free.

The book reorganizes the series above into a path from fundamentals to production, then adds chapters on operations, testing, and a capstone project to make it work as one complete book.

How this book is funded #

This book is funded by site ads (AdSense) and reader support. There is no purchase flow, and all 34 chapters are open to read on the site.

If a chapter helps you, you can support the book on Ko-fi. Reader support is what makes the time for the next minor revisions and the next book.

❤️ Support on Ko-fi (from $1)

Frequently asked questions #

What do I need for the learning environment #

Python 3.14 or later, uv, and one code editor are enough. The Part 4 FastAPI chapters use only SQLite and deployment services that fit within free tiers. No step in the book requires a payment.

Where can I get the book’s code #

Each chapter’s example code is written directly in the body as code blocks, so we recommend typing it out by hand as you learn. The finished version of the Part 4 capstone TODO API will be provided separately as a GitHub repository. We will add the link to this book page once it is ready.

Will the book be obsolete when the next Python version ships #

The core model (the uv workflow, type-hints-first, dataclass · Protocol, asyncio, FastAPI + Pydantic v2) should hold for at least the next 2 ~ 3 years of releases. Changed syntax and library APIs are folded into minor revisions (e.g., v1.1), and once larger changes accumulate, a v2 book line can start separately.

Can I read this in languages other than English #

Korean, Japanese, and English are all published with the same 34-chapter structure. You can read each from its own book page.

Isn’t a chapter more than 70 % the same as a post on the site #

Some chapters share a topic with the source series posts. But each book chapter is rewritten — (1) re-narrated to fit the book’s flow, (2) unified to the Python 3.14 + uv + type-hints baseline, (3) cross-linked with other chapters in the book, and (4) given exercises and a one-line summary — so even on the same topic the result reads as different material. The 7 new chapters and Appendix A are not in the source series.

How do I send support or feedback #

Feedback is welcome through blog comments or email. Typos, improvement suggestions, and code error reports per chapter are folded quickly into the next minor revision. Support runs through the Ko-fi channel, from $1 and up.

What’s next #

All 34 chapters in ko · ja · en are published. Updates will proceed as follows.

  1. Stabilizing the v1 text — over the 4 ~ 8 weeks after release, reader feedback folds typos, code errors, and thin explanations into minor revisions (v1.x). The same revisions are applied to all three languages together.
  2. Part 4 capstone GitHub repository — the finished TODO API will be organized into a separate repository, with the link added to this book page.
  3. Regular Python updates — new minor versions and library changes are reviewed and reflected on a six-month cadence. Once larger changes accumulate, a v2 book line can begin.

You can subscribe to new-chapter and major-revision notices via the RSS feed.

Contents

Part 3: Depth and Concurrency 7 Chapter

Magic methods · descriptors · metaclasses · asyncio in depth · GIL · advanced typing · performance profiling.

  1. 15. Magic methods in depth and protocols Every hook where Python objects integrate with language features. __call__, __getitem__, __hash__, __format__, __getattr__ — gathered in one place.
  2. 16. Descriptors and __set_name__ How property works — the __get__/__set__ protocol and data/non-data descriptors, and clean validation fields with __set_name__.
  3. 17. Metaclasses — when do you really need them? Covers classes that build classes. The identity of type, the division with __init_subclass__, cases that class decorators solve, and the narrow areas where you really need a metaclass.
  4. 18. Async in depth — event loop, gather/wait, async generator The next step from the intermediate intro — how the event loop actually works, the difference between Future and Task, gather vs wait, async generators and async iteration.
  5. 19. GIL and concurrency — threading vs multiprocessing vs asyncio The identity of the GIL, the division between threading/multiprocessing/asyncio, and the free-threaded builds of Python 3.13~3.14 (PEP 703/779) — all in one place.
  6. 20. Advanced typing — Variance, ParamSpec, Self, overload The next step from intermediate typing — covariance/contravariance, ParamSpec and Concatenate, Self, TypeGuard/TypeIs, and @overload.
  7. 21. Performance — cProfile, py-spy, memory profiling The toolbox for finding and fixing slow Python code — timeit, cProfile, py-spy, line_profiler, memray, and common optimization patterns.
Part 4: FastAPI in Production 8 Chapter

FastAPI · Pydantic v2 · SQLAlchemy 2.x · JWT auth · background jobs · testing and deploy. Closes with the full TODO API capstone.

  1. 22. FastAPI setup and getting started Why FastAPI, first project setup with uv, Hello FastAPI, automatic OpenAPI/Swagger UI generation — all in one place.
  2. 23. Routing, Pydantic models, and dependency injection Splitting routes with APIRouter, defining input/output schemas with Pydantic v2, and factoring shared logic out with Depends.
  3. 24. Pydantic v2 in depth — validation, serialization, custom validators A dedicated deep dive on Pydantic, the core of FastAPI. v2's performance and API changes, the right places to use model_validator/field_validator, serialization control, and JSON Schema generation.
  4. 25. Connecting a DB — SQLAlchemy 2.x + Alembic SQLAlchemy 2.x's new style — Mapped/mapped_column, async sessions, integration with FastAPI's dependency injection, and Alembic migrations.
  5. 26. Authentication — OAuth2 password flow + JWT Password hashing (argon2/bcrypt), the OAuth2 password flow, JWT issuance/verification, and the current_user dependency that wraps it all into a clean auth pattern.
  6. 27. Async and background jobs When to use async routes, BackgroundTasks for post-response work, the boundary where external queues (Celery, ARQ) start to be needed, and how to safely mix in sync libraries.
  7. 28. Testing and deploy — pytest, Docker, Railway/Fly FastAPI integration tests with pytest + httpx, isolation via dependency overrides, multi-stage Docker builds, and cloud deployment on Railway/Fly.
  8. 29. Capstone — finishing the TODO API Tie the patterns from Chapters 1 ~ 28 into a single working service. Authenticated per-user TODO CRUD, tag filtering, pagination, background notifications, tests, and deploy.
X