Skip to main content

larztoml

TOML read and write. Pure Python (back to 3.8), zero dependencies.

The standard library gained tomllib in 3.11 — but it only reads, and only on new Pythons. larztoml both parses and serializes TOML, on any supported Python, with no dependency.

from larztoml import loads, dumps

cfg = loads("""
title = "myapp"

[server]
host = "localhost"
port = 8080
tags = ["a", "b"]

[[user]]
name = "Ada"
""")

dumps(cfg)      # back to TOML text

Why

  • It writes. dumps() is the piece tomllib doesn't have — generate config files, not just read them.
  • Works everywhere. Python 3.8+, not just 3.11+.
  • Real TOML. [tables], [[arrays of tables]], nested and dotted keys, typed values (strings incl. literal/multiline, ints/floats with _ and hex/oct/bin, inf/nan, bools, dates and datetimes), arrays (including multi-line), inline tables, and comments.
  • Zero dependencies. No toml, no tomli/tomli-w.

Install

pip install larztoml

Usage

from larztoml import loads, dumps

data = loads(open("pyproject.toml").read())
text = dumps({"tool": {"app": {"port": 8080, "hosts": ["a", "b"]}}})

Dates parse to datetime/date/time; numbers keep their type. Round-trips: loads(dumps(obj)) == obj for the supported subset.

Tests

python -m unittest discover -s tests -v   # 21 tests incl. dump round-trips

The Larz stack

One of 30+ pure-Python, zero-dependency libraries at github.com/larz-scripter — pairs with larzconf and larzyaml.

License

MIT © larz-scripter

Metadata

Release files for larztoml 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for larztoml 0.1.0
File Size Uploaded Provenance
larztoml-0.1.0.tar.gz 7.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for larztoml 0.1.0
File Interpreter ABI Platform
larztoml-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.0 kB

Release files / larztoml-0.1.0.tar.gz

Download URL larztoml-0.1.0.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7d69abfb559d8c89b0f62b019528fd433dd675ad244f2ed82d08e9f3a01d48a5
BLAKE2b-256 checksum
How to use checksums
5367a08615169aec6268f636282694baaeb95f5b27c4a4a52cdb88916c1faf0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / larztoml-0.1.0-py3-none-any.whl

Download URL larztoml-0.1.0-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3432bb66cab3fcc07543fbda1219446dce08fce4749d01a5c68e02ce25fac255
BLAKE2b-256 checksum
How to use checksums
90f5b68917ff3f3204402b3cd7eac9f8a69e1079d4e3523bc855ae9c3057e4cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for larztoml 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page