Tutorial
This tutorial walks through PythonizeYAML from first principles: loading and dumping, editing values in place, controlling comments and styles, and loading untrusted input safely. Each chapter builds on the previous ones and ends where the API reference takes over.
PythonizeYAML is a YAML library with a PyYAML-compatible API and a lossless round-trip engine: loading a document, changing a value, and dumping it again reproduces the original file byte for byte everywhere you did not touch.
The chapters use import pythonizeyaml as yaml throughout, so the examples read like PyYAML code.
- Loading and dumping -
load(),dump(), document objects, and the round-trip guarantee. - Editing values - paths, assignment,
set(), sequences, and building documents from scratch. - Command line - the
yamlshell command for path-basedget/set/deledits. - Comments, styles, tags, and anchors - the style-aware editing layer carried by the values themselves.
- Loading untrusted YAML -
safe_load(),Tagged, and the error model at a trust boundary.
When you want complete, runnable projects instead of isolated snippets, see the worked examples: