pythonbeginner

Toml Config

Advanced Python pattern: toml-config

python
import tomllib
from pathlib import Path

Path('pyproject.toml').write_text('[tool.demo]\nname = "snippetslab"\n')
obj = tomllib.loads(Path('pyproject.toml').read_text())
print(obj['tool']['demo']['name'])

Use Cases

  • advanced programming
  • patterns

Tags

Related Snippets

Similar patterns you can reuse in the same workflow.