Python guides
Every published Python guide, newest first, with practical examples you can copy into your own project.
3,965 guides across 14 topics
Topics
Popular Python guides
Most readLatest Python guides
Page 2 of 179Pydantic v2 vs dataclasses vs TypedDict: Speed and Memory
TypedDict validates nothing, a dataclass accepts the wrong type, and Pydantic pays for a compiled validator. A reproducible benchmark and where each belongs.
Python asyncio: Event Loop Is Closed and Blocking Calls
asyncio.run closes its loop, so a cached client or pool dies with the second call. Where the loop lifetime belongs, and how to keep blocking IO from stalling every task.
CSV to JSON in Python: Encoding, Types, and Serialization Pitfalls
CSV has no types, so every conversion is a guess. Four settings decide whether the output is faithful: the encoding, the newline mode, the dialect, and how NaN is serialized.
FastAPI 422: Custom Validation Errors and Response Models
Three exceptions share the 422 path and only one is handled by default. A single handler that strips input and flattens loc gives clients a contract that survives a Pydantic version change.
uv Resolution Errors: Reading No solution found and Lock Drift
The last Because clause is the contradiction and everything above it is context. Then decide: relax a pin, narrow requires-python, or change index strategy.
Python 3.12 Generics: PEP 695 Syntax, Type Parameters, and TypeVar
How Python 3.12 PEP 695 type parameter syntax works: bracket declarations for classes, functions, and type aliases, bounds and constraints, inferred variance, lazy evaluation, and the runtime scope rules.
Python Asyncio: Event Loop and Tasks Explained
How the asyncio event loop schedules coroutines and tasks in Python, with concurrency patterns, TaskGroup, cancellation, timeouts, and the failure modes that break production services.
Python Kafka: kafka-python vs Confluent Client
kafka-python is pure Python; confluent-kafka wraps librdkafka. Compare APIs, throughput, error handling, and pick the client that fits your service.
Python Confluent Kafka Producer Consumer and Schema Registry
python confluent kafka producer consumer and schema registry: Learn to build a Python Kafka producer and consumer with Confluent's client and Schema Registry, covering...
Python Kafka Offsets, Partitions, and Manual Commits
Learn how Kafka offsets and partitions work and how to manually commit offsets in Python consumers with kafka-python and confluent-kafka. Covers sync vs async commits, rebalances, and seeking.