python-tomli-w
Port variant v14
Summary Lil' TOML writer (3.14)
Package version 1.2.0
Homepage https://github.com/hukkin/tomli-w
Keywords python
Maintainer Python Automaton
License Not yet specified
Other variants v13
Ravenports Buildsheet | History
Ravensource Port Directory | History
Last modified 24 JUL 2026, 16:11:02 UTC
Port created 24 JUL 2026, 16:11:02 UTC
Subpackage Descriptions
single [Build Status] [![codecov.io]](https://codecov.io/gh/hukkin/tomli-w) [PyPI version] # Tomli-W > A lil' TOML writer **Table of Contents** *generated with [mdformat-toc]* - [Intro] - [Installation] - [Usage] - [Write to string] - [Write to file] - [FAQ] - [Does Tomli-W sort the document?] - [Does Tomli-W support writing documents with comments?] - [Can I customize insignificant whitespace?] - [Why does Tomli-W not write a multi-line string if the string value contains newlines?] - [Is Tomli-W output guaranteed to be valid TOML?] ## Intro Tomli-W is a Python library for writing [TOML]. It is a write-only counterpart to [Tomli], which is a read-only TOML parser. Tomli-W is fully compatible with [TOML v1.0.0]. ## Installation ```bash pip install tomli-w ``` ## Usage ### Write to string ```python import tomli_w doc = {"table": {"nested": {}, "val3": 3}, "val2": 2, "val1": 1} expected_toml = """\ val2 = 2 val1 = 1 [table] val3 = 3 [table.nested] """ assert tomli_w.dumps(doc) == expected_toml ``` ### Write to file ```python import tomli_w doc = {"one": 1, "two": 2, "pi": 3} with open("path_to_file/conf.toml", "wb") as f: tomli_w.dump(doc, f) ``` ## FAQ ### Does Tomli-W sort the document? No, but it respects sort order of the input data, so one could sort the content of the `dict` (recursively) before calling `tomli_w.dumps`. ### Does Tomli-W support writing documents with comments? No. ### Can I customize insignificant whitespace? Indent width of array content can be configured via the `indent` keyword argument. `indent` takes a non-negative integer, defaulting to 4. ```python import tomli_w doc = {"fruits": ["orange", "kiwi", "papaya"]} expected_toml = """\ fruits = [ "orange", "kiwi", "papaya", ] """
Configuration Switches (platform-specific settings discarded)
PY313 OFF Build using Python 3.13 PY314 ON Build using Python 3.14
Package Dependencies by Type
Build (only) python314:dev:std
python-pip:single:v14
autoselect-python:single:std
Build and Runtime python314:primary:std
Download groups
main mirror://PYPIWHL/c7/18/c86eb8e0202e32dd3df50d43d7ff9854f8e0603945ff398974c1d91ac1ef
Distribution File Information
188306098d013b691fcadc011abd66727d3c414c571bb01b1a174ba8c983cf90 6675 python-src/tomli_w-1.2.0-py3-none-any.whl
Ports that require python-tomli-w:v14
python-nab-python:v14 Nab package index provider (3.14)