TOML and Python

Liste des GroupesRevenir à cl python 
Sujet : TOML and Python
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram)
Groupes : comp.lang.python
Date : 06. Jul 2024, 15:42:48
Autres entêtes
Organisation : Stefan Ram
Message-ID : <TOML-20240706144158@ram.dialup.fu-berlin.de>
  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"
        }
    }
}

Date Sujet#  Auteur
6 Jul 24 * TOML and Python2Stefan Ram
7 Jul 24 `- Re: TOML and Python (Posting On Python-List Prohibited)1Lawrence D'Oliveiro

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal