{"id":6212,"library":"pytoml","title":"pytoml","description":"pytoml is a Python library designed for parsing and writing TOML (Tom's Obvious, Minimal Language) files. It specifically targets version 0.4.0 of the TOML specification. The library provides an interface similar to Python's standard `json` module, offering `load`, `loads`, `dump`, and `dumps` functions. The project is no longer actively maintained, with its last release (0.1.21) in July 2019.","status":"deprecated","version":"0.1.21","language":"en","source_language":"en","source_url":"https://github.com/avakar/pytoml","tags":["TOML","configuration","parser","deprecated"],"install":[{"cmd":"pip install pytoml","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The common and recommended practice is to import `pytoml` as `toml` to align with other TOML libraries and the common CLI tool name.","wrong":"import pytoml","symbol":"load, loads, dump, dumps","correct":"import pytoml as toml"}],"quickstart":{"code":"import pytoml as toml\nimport io\n\n# Loading from a string\ntoml_string = 'title = \"My TOML Document\"\\nowner = { name = \"John Doe\" }'\ndata_from_string = toml.loads(toml_string)\nprint(f\"From string: {data_from_string}\")\n\n# Loading from a file-like object (e.g., a file)\n# Using io.BytesIO to simulate reading a file in binary mode ('rb')\ntoml_file_content = b'[database]\\nserver = \"192.168.1.1\"\\nports = [8001, 8002, 8003]'\nfile_like_object = io.BytesIO(toml_file_content)\ndata_from_file = toml.load(file_like_object)\nprint(f\"From file-like object: {data_from_file}\")\n\n# Dumping to a string\ndict_to_dump = {'server': '10.0.0.1', 'connection_max': 5000}\ndumped_string = toml.dumps(dict_to_dump)\nprint(f\"Dumped TOML string:\\n{dumped_string}\")","lang":"python","description":"Demonstrates loading TOML data from a string and a file-like object, and dumping a Python dictionary to a TOML string. Note that `load` expects a binary-read file object (e.g., opened with 'rb')."},"warnings":[{"fix":"Migrate to actively maintained TOML parsers such as `tomli` (standard library in Python 3.11+, read-only) or `tomlkit` (for full round-trip preservation and writing).","message":"The `pytoml` library is officially deprecated and no longer actively maintained. Its GitHub README explicitly advises users to consider alternatives. This means it will not receive updates for new Python versions, TOML specification changes, or security fixes.","severity":"breaking","affected_versions":"All versions, especially 0.1.21 and older"},{"fix":"Switch to a TOML 1.0.0 compliant parser. `tomli` (for Python 3.6-3.10 and earlier 3.11+, read-only) and `tomlkit` (for full TOML 1.0.0 support, including preserving formatting) are recommended alternatives.","message":"pytoml only supports TOML specification version 0.4.0. The current stable TOML specification is 1.0.0. Using `pytoml` with modern `pyproject.toml` files or other TOML 1.0.0 compliant configurations will likely lead to parsing errors or incorrect data interpretation due to syntax changes between versions.","severity":"breaking","affected_versions":"All versions, as it's an inherent design limitation."},{"fix":"Always open TOML files for reading with `with open('your_file.toml', 'rb') as f: data = toml.load(f)`.","message":"When using `toml.load()`, the file object must be opened in binary read mode (`'rb'`). Passing a text-mode file object (`'r'`) will result in a `TypeError` or unexpected behavior.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z","problems":[]}