[CentralOH] YAML versus Python

jep200404 at columbus.rr.com jep200404 at columbus.rr.com
Thu Nov 13 02:19:44 CET 2014

I saw some complex data for initial values in an ugly format. 
Someone else saw it and immediately said to use YAML. 

I realized that if the configuration data is used only in a 
Python program, then the configuration data could be a Python 
module, and just be imported. So now I'm wondering about YAML 
versus Python. When is YAML more helpful than Python and vice 

If one needs to use the data in any language other 
than Python, then Python would be inappropriate, because one 
would need a Python parser for some other language, which 
would be rediculous. YAML can be grokked by many languages.

If one needs modify the data by a program, 
then YAML is superior because it's easy to output. 
Importing Python is easy, but I'm not aware of a way to easily 
output Python. print(repr(foo)) could be a part of it,
but it tends towards long lines which are hard to read. 

The references in YAML are interesting.
It makes me wonder about recursive references in Python. 
I had not though about recursive data structures in Python.
(I have not needed them yet either.)

Also, as clean as Python is, it has more syntax cruft to wade 
through than YAML. YAML is easier to read. 

Golly, I think I've talked myself into YAML.
What can you add about YAML versus Python for static or 
initializing data?

More information about the CentralOH mailing list