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 30 of 179Python Pydantic model_dump and model_validate Explained
Pydantic v2's model_validate() turns external data into a validated model, while model_dump() turns a model back into a plain dictionary. This guide covers when to use each method, how to include or exclude fields, and common mistakes.
Python Pydantic Aliases and Serialization
Learn how Pydantic aliases affect serialization and how to use by_alias and populate_by_name to control field names in model_dump and JSON output.
Python Pydantic Optional Fields: Defaults & default_factory
Learn how to define optional fields in Pydantic, what `Optional[T]` actually means, and how `default_factory` differs from a plain `default` for mutable default values.
Pydantic field_validator and model_validator in Python
Learn how to use Pydantic's field_validator and model_validator for single-field and cross-field validation, including syntax and practical examples.
Python Pydantic BaseModel Fields and Validation
How Pydantic BaseModel fields validate data: type coercion, Field constraints, validators, nested models, error handling, and validation overhead.
Python LangChain vs Direct OpenAI API: Which to Use
Compare Python LangChain and the direct OpenAI API for LLM calls: dependency footprint, debugging, orchestration features, and when to choose each.
Python LangChain OpenAI Integration
Set up the Python LangChain OpenAI integration with ChatOpenAI: install the packages, configure the API key, build prompt chains, stream responses, handle errors, and plan for production.
Implementing Streaming and Async in Python LangChain
Learn how to combine streaming and async in Python LangChain to build responsive LLM applications. Includes token streaming, async calls, error handling, and concurrency.
Python LangChain RAG Implementation: A Practical Pipeline
A practical guide to building a RAG pipeline in Python with LangChain: load documents, split and embed chunks, store vectors, retrieve relevant context, and generate answers with an LLM.
Python LangChain Embeddings, Vector Stores, and Retrievers
Build semantic search and RAG pipelines with Python LangChain embeddings, vector stores, and retrievers.