Python TomlLib

tomllib is a module that supports (de-)serializing TOML files.

This was added in Python 3.11.


Usage

TOML and Python objects are translated as:

TOML

Python

table

dict

string

str

integer

int

float

float (configurable with parse_float)

boolean

bool

offset date-time

datetime.datetime (tzinfo attribute set to an instance of datetime.timezone)

local date-time

datetime.datetime (tzinfo attribute set to None)

local date

datetime.date

local time

datetime.time

array

list


Load

Deserialize a binary TOML file.

with open("pyproject.toml", "rb") as f:
    config = tomllib.load(f)


LoadS

Deserialize a TOML string.


See also

Python toml module documentation


CategoryRicottone

Python/TomlLib (last edited 2023-04-11 14:45:09 by DominicRicottone)