larzyaml
A practical YAML subset — load and dump. Pure Python, zero dependencies.
Covers the YAML people actually write for config: nested mappings and sequences,
plain and quoted scalars with type inference, inline flow collections, and #
comments — the 95% that config files use, without a dependency.
from larzyaml import load, dump
load("""
name: myapp
port: 8080
debug: true
hosts:
- a.com
- b.com
db: {host: localhost, port: 5432}
""")
# {'name': 'myapp', 'port': 8080, 'debug': True,
# 'hosts': ['a.com', 'b.com'], 'db': {'host': 'localhost', 'port': 5432}}
Why
- No dependency.
PyYAMLpulls in a C extension (or a big pure-Python parser); larzyaml is a few hundred readable lines for the common cases. - The config subset, done right. Nested maps/sequences by indentation,
sequence-of-maps (
- key: value), typed scalars (1,2.5,true,null), inline[...]/{...}, and quote-aware comment stripping. - Round-trips.
dump()re-serializes, quoting ambiguous strings ("true","123") so they load back as strings.
Not the full spec — no anchors, tags, or block scalars. For config files, fixtures, and simple data, that's exactly enough. Pairs with larzconf.
Install
pip install larzyaml
Usage
from larzyaml import load, dump
data = load(open("config.yaml").read())
text = dump({"name": "app", "hosts": ["a", "b"], "db": {"port": 5432}})
Tests
python -m unittest discover -s tests -v # 18 tests incl. dump round-trips
The Larz stack
One of 30+ pure-Python, zero-dependency libraries at github.com/larz-scripter.
License
MIT © larz-scripter
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file larzyaml-0.1.0.tar.gz.
File metadata
- Download URL: larzyaml-0.1.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2660e4bab477ece78d312bc16400405e77d91e64cbc23151d3b90df9b5162af5
|
|
| MD5 |
21a04865413147f73d8dd7f17194d6cf
|
|
| BLAKE2b-256 |
68d0f57ce426187b661d55e5e8b4152516369c4e0bf9051241379c9a590aaf8a
|
File details
Details for the file larzyaml-0.1.0-py3-none-any.whl.
File metadata
- Download URL: larzyaml-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fdf4a7c00018fef78841fc1ff763e75088ee34d145f90e2e1c3caffce9846436
|
|
| MD5 |
635d58f9f11684e1774a86251ddca26a
|
|
| BLAKE2b-256 |
cb64e0f205ceeae570b7005fd1843ec68283e576582f0a8ad0daeb403cfb640d
|