PyYaml in standard library?

Brendan Miller catphive at catphive.net
Wed Feb 18 17:31:16 EST 2009


On Wed, Feb 18, 2009 at 1:34 AM, Chris Rebert <clp2 at rebertia.com> wrote:
> On Wed, Feb 18, 2009 at 1:11 AM, Brendan Miller <catphive at catphive.net> wrote:
>> I'm just curious whether PyYaml is likely to end up in the standard
>> library at some point?
>
> I don't personally have a direct answer to your question, but I can
> point out that JSON and YAML are mostly compatible (JSON is almost a
> perfect YAML subset) and the `json` module is already in the Python
> std lib.
>
> Cheers,
> Chris

Yes, JSON is an (I think unintentional) subset of YAML... but a fairly
small subset.

A list in YAML looks like

--- # my list
- Elem 1
- Elem 2

Whereas in JSON you have ["Elem 1", "Elem 2"]. People say JSON is a
subset because YAML will also accept the JSON style syntax if you want
to do something inline for convenience:

--- # my list containing a sublist in the second element.
- Elem 1
- ["Sub elem 1", "Sub elem 2"]

But this is really a special purpose syntax in the context of YAML.

I think the json module sticks everything on the same line, which
isn't readable for large data structures. My impression is YAML is
that is is more readable than JSON, whereas JSON is mostly for browser
interop.



More information about the Python-list mailing list