What does it do?
PyYAML reads and writes YAML, a file format designed to be readable by actual humans, the kind of file where settings are laid out with indentation and plain words instead of cryptic brackets and quotes. It’s a bit like a librarian who can read handwritten notes and file them into a proper database, or do the reverse. Nearly every settings file you’d open and make sense of at a glance without a programming background is probably YAML, and PyYAML is what lets Python programs actually load and use it. It also lets programs write out YAML files that a human can then edit by hand.
See it in action
This turns a small set of settings into readable YAML text, and separately shows how to read a YAML settings file back into the program.
import yaml
data = {"name": "Ada", "roles": ["admin", "editor"]}
print(yaml.dump(data))
with open("config.yaml") as f:
config = yaml.safe_load(f)
print(config)
Why would a non-developer care?
If you’ve ever peeked into a project’s setup files and seen something oddly readable with dashes and colons instead of dense code, that was likely YAML, popular precisely because it’s meant for people, not just machines. That readability is why it became the standard way teams write configuration for so much modern software.
Real-world examples
YAML files power the automation behind GitHub Actions, the configuration for Docker Compose, and the deployment specs for Kubernetes, arguably three of the most common ways modern software gets built and shipped. PyYAML is frequently the library quietly parsing those files whenever Python is involved in the tooling.
Who uses it
Developers and DevOps engineers who write configuration files for automation pipelines, containers, and cloud infrastructure.
How it compares to alternatives
Compared to toml, which was designed to be even simpler and less error-prone, YAML is more flexible and more widely adopted but has a reputation for subtle formatting gotchas, like the famous case where the country code NO gets misread as the boolean value false. JSON is YAML’s stricter, less human-friendly cousin.
Fun fact
YAML officially stands for “YAML Ain’t Markup Language,” a recursive joke acknowledging that, unlike XML, it was never meant to be a markup language at all.