Skip to main content
Loading page…
Python Mastery
Chapter 23
Lesson 3 of 3
Config: TOML, YAML, INI & .env
Contents
Notes
Tutor
Concept
The Config Format Landscape
Loading activity…
Previous
1 / 10
Continue
Contents
Notes
Discussion
Tutor
26 min
10 activities
0 of 10 done
In this lesson
1
The Config Format Landscape
2
TOML with tomllib (Python 3.11+)
3
YAML with pyyaml (safe_load Only)
4
Layered Config: Defaults < File < Environment
5
configparser for INI Files and python-dotenv for .env
6
Exercise: TOML Config Loader with Env Override
7
YAML Security: yaml.safe_load Only
8
Config Format Selection
9
Config Format Knowledge Check
10
Layered Config Design
Objectives
Read and write TOML configuration using the stdlib tomllib (Python 3.11+)
Parse YAML configuration files using pyyaml safely
Use configparser to read and write INI-style configuration
Load .env files with python-dotenv and access values via os.environ
Implement a layered config system where env vars override file values which override defaults
Choose the right config format based on use case
Chapter 23 · Serialization, Config & Data Interchange
JSON, Deeply
pickle & Its Dangers
Config: TOML, YAML, INI & .env
Previous: pickle & Its Dangers
Next: Big-O & Python Operation Costs