Best way to store config or preferences in a multi-platform way.
Ivan Illarionov
ivan.illarionov at gmail.com
Thu May 1 16:26:35 EDT 2008
On Thu, 01 May 2008 14:13:08 -0500, Jon Ribbens wrote:
> On 2008-05-01, Ivan Illarionov <ivan.illarionov at gmail.com> wrote:
>> I used XML files before for this purpose and found YAML much easier and
>> better suitable for the task.
>>
>> Please explain why don't like YANL so much?
>
> Because even the examples in the spec itself are unreadable gibberish.
> The PyYAML library is over 300kB! These are rather big clues that it's
> unsuitable for the purpose for which it was designed. It's certainly
> unsuitable for use as a configuration file format, where it is overkill
> by several orders of magnitude.
>
> !!str &a1 "foo":
> !!str bar
> &a2 baz : *a1
> !<tag:yaml.org,2002:str> foo :
> !<!bar> baz
>
> This is supposed to be human readable?
Thanx, now I see your point. I didn't mean all the fancy features of
YAML, but the most basic sintax.
Compare this:
<user id="babooey" on="cpu1">
<firstname>Bob</firstname>
<lastname>Abooey</lastname>
<department>adv</department>
<cell>555-1212</cell>
<address password="xxxx">ahunter at example1.com</address>
<address password="xxxx">babooey at example2.com</address>
</user>
and this:
babooey:
computer : cpu1
firstname: Bob
lastname: Abooey
cell: 555-1212
addresses:
- address: babooey at example1.com
password: xxxx
- address: babooey at example2.com
password: xxxx
I find the latter *much* more readable.
And the most important thing is that it *maps directly to Python data
types*, in this case dictionaries and lists:
{babooey: {computer: cpu1, firstname: Bob, lastname: Abooey, cell: 555,
1212, addresses: [{address: babooey at example1.com, password: xxxx},
{address: babooey at example2.com, password: xxxx}]}
I took the example from
http://www.kuro5hin.org/story/2004/10/29/14225/062
I haven't use my own example only because I don't have one at hand right
now. YAML, in its simple form, definetely makes me more productive. I
wasted too much time with XML in the past and I won't ever use it as a
serialization or config/settings format again. .INI/ConfigParser is too
limited and has no standards. I just don't see anything better than YAML
to do human and Python editable config files and to serialize information
for later use.
>> PS. Your reply remind me of early days of Python when Perl programmers
>> said exacly the same thing about Python.
>
> I think I would suffer irony overload if I saw a Perl programmer
> criticising Python for being hard to read ;-)
More information about the Python-list
mailing list