Pages

Topics

Tools

↑↓navigate↵openescclose

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

Latest Python guides

Comparison of jsonschema and pydantic validation approaches in Python
Python

python jsonschema vs pydantic: Choosing the Right Validation Tool

Compare jsonschema and Pydantic for Python data validation: declarative JSON Schema vs type-hint-based models, type coercion, error handling, and when to use each.

JSON SchemaPydanticData ValidationType Hints
Illustration of a JSON document failing format validation with a ValidationError raised in Python
Python

Python jsonschema Formats and Validation Errors

python jsonschema formats and validation errors: Learn how jsonschema format validation works, why formats are ignored by default, and how to read and handle Validatio...

jsonschemaJSON SchemaPython validationerror handling
Diagram showing a JSON document with required fields, nested objects, and arrays being validated by Python jsonschema.
Python

Python jsonschema: Validate Required Nested and Arrays

python jsonschema validate json required nested and arrays: Learn how to use Python jsonschema to validate JSON with required fields, nested objects, and arrays, inclu...

jsonschemaJSON validationrequired fieldsnested objects
Comparison of Python tomllib and tomlkit TOML parsing libraries, showing read-only vs round-trip editing.
Python

Python tomllib vs tomlkit: Which TOML Parser?

python tomllib vs tomlkit: Compare Python's tomllib and tomlkit for reading and editing TOML files. Learn which library fits your parsing and round-trip needs.

TOMLtomllibtomlkitPython configuration
Illustration of a TOML configuration file being edited with Python's tomlkit library while preserving its comments and formatting.
Python

Read, Modify, and Write TOML with Python tomlkit

Learn how to read, modify, and write TOML files in Python with the tomlkit library while preserving comments, key order, and formatting.

tomlkitTOMLconfiguration filespyproject.toml
Illustration of a Python script reading a pyproject.toml file using the tomllib module
Python

Python tomllib: Read pyproject.toml Files

Read pyproject.toml with Python's tomllib: TOML loading, nested data, error handling, and tomli on older Python versions.

tomllibpyproject.tomlTOML parsingconfiguration files
Abstract illustration of a YAML document tree with a highlighted custom tag node connected to a Python class symbol, representing PyYAML custom tag handling.
Python

Python PyYAML Custom Tags: Load and Dump Custom Types

Learn how to register custom YAML tags in PyYAML with constructors and representers, load custom Python types safely, and handle unknown tags.

PyYAMLYAMLPythonCustom Tags
Illustration of a YAML file with indented keys and list items being transformed into Python dictionary and list structures, with a document separator line indicating multiple documents.
Python

Python PyYAML: Dictionaries, Lists, and Multiple Documents

Learn how PyYAML maps YAML to Python dictionaries and lists, loads nested data, and parses multiple documents from one stream with safe_load_all.

PyYAMLYAML parsingPython dictionariesPython lists
A visual comparison of safe_load and load in PyYAML, showing a shield protecting basic data types while load exposes arbitrary code execution.
Python

PyYAML safe_load vs load: Which One Should You Use?

PyYAML safe_load vs load: why safe_load is the secure default, how unsafe loaders can execute arbitrary code, and when a custom SafeLoader is the right choice.

PyYAMLYAML parsingsecuritydata serialization
Illustration of a Python script using PyYAML to safely read and write YAML files, with a shield icon representing security.
Python

Python PyYAML: Read and Write YAML Safely

Learn how to use PyYAML's safe_load() and safe_dump() to read and write YAML files without exposing your application to code injection.

PyYAMLYAMLPythonsafe_load