• TOML and Python

    From Stefan Ram@3:633/280.2 to All on Sat Jul 6 23:42:48 2024
    A structure with information can be represented in TOML,
    see example [1]. However, equivalent information also could
    be written in pure Python and possibly be parsed with ast.
    literal_eval, see example [2].

    Since we already have Python, why do we need TOML in
    addition?

    What advantages do you see in using TOML for ini or config
    files instead of Python?

    When is it better to use TOML and when is it better to user
    Python to represent structured information?

    TIA!

    [1]

    # This is a TOML document

    title = "TOML Example"

    [owner]
    name = "Tom Preston-Werner"
    dob = 1979-05-27T07:32:00-08:00

    [database]
    server = "192.168.1.1"
    ports = [ 8000, 8001, 8002 ]
    connection_max = 5000
    enabled = true

    [servers]

    [servers.alpha]
    ip = "10.0.0.1"
    dc = "eqdc10"

    [servers.beta]
    ip = "10.0.0.2"
    dc = "eqdc10"

    [2]

    config = {
    "title": "TOML Example",
    "owner": {
    "name": "Tom Preston-Werner",
    "dob": "1979-05-27T07:32:00-08:00"
    },
    "database": {
    "server": "192.168.1.1",
    "ports": [8000, 8001, 8002],
    "connection_max": 5000,
    "enabled": True
    },
    "servers": {
    "alpha": {
    "ip": "10.0.0.1",
    "dc": "eqdc10"
    },
    "beta": {
    "ip": "10.0.0.2",
    "dc": "eqdc10"
    }
    }
    }

    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: Stefan Ram (3:633/280.2@fidonet)