PythonizeYAML
A PyYAML-compatible YAML library with lossless round trips.
Lossless round trips
Preserve comments, indentation, scalar styles, and document layout while editing values.
PyYAML-compatible API
Load and dump YAML with familiar functions such as load, dump, safe_load, and safe_dump.
Style-aware documents
Use Document to edit comments, tags, anchors, aliases, and formatting on the values themselves.
PythonizeYAML keeps the existing source layout when a document is loaded, edited, and dumped again.
Install
pip install pythonizeyaml
Quick example
import pythonizeyaml as yaml
document = yaml.load("service:\n port: 8080\n")
document["service"]["port"] = 9090
print(yaml.dump(document))
The tutorial walks through loading, editing, and style-aware editing step by step. The API reference lists exact signatures, arguments, and class members for every public interface.