#Python

147 posts

Authentication — OAuth2 password flow + JWT
9 min read

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.

Building CLI tools (Typer)
9 min read

Building CLI tools (Typer)

How to build a type-hints-first CLI with Typer instead of argparse. Subcommands, autocompletion, and Rich-powered output.

Capstone — finishing the TODO API
15 min read

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.

Collections and comprehensions
9 min read

Collections and comprehensions

The four collections — list/tuple/dict/set — and the comprehensions and generator expressions that build new collections in one line.

Connecting a DB — SQLAlchemy 2.x + Alembic
9 min read

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.

Context managers (with, contextlib)
7 min read

Context managers (with, contextlib)

with that turns try/finally into one line, building your own with __enter__/__exit__, @contextmanager for constructor-short forms, and practical tools like ExitStack/suppress.

Control flow — if, while, for, match-case
8 min read

Control flow — if, while, for, match-case

Flow control where blocks come from indentation, range/enumerate/zip, and match-case pattern matching that differs in feel from switch.

dataclass and __slots__
8 min read

dataclass and __slots__

Every option of @dataclass for short, safe data classes — frozen, kw_only, field() — plus __slots__ for memory savings, all in one place.

Decorator patterns
8 min read

Decorator patterns

Every shape of decorator that wraps a function — the basic form, decorators with arguments, functools.wraps, class decorators, and ParamSpec.

Descriptors and __set_name__
8 min read

Descriptors and __set_name__

How property works — the __get__/__set__ protocol and data/non-data descriptors, and clean validation fields with __set_name__.

Errors and exception handling
8 min read

Errors and exception handling

The roles of try/except/else/finally, raise and user-defined exceptions, and the ExceptionGroup and except* introduced in 3.11.

FastAPI setup and getting started
8 min read

FastAPI setup and getting started

Why FastAPI, first project setup with uv, Hello FastAPI, automatic OpenAPI/Swagger UI generation — all in one place.