[Python-ideas] PEP 426, YAML in the stdlib and implementation discovery

Andrew Barnert abarnert at yahoo.com
Fri May 31 21:01:01 CEST 2013


>From: Masklinn <masklinn at masklinn.net>
>Sent: Friday, May 31, 2013 11:18 AM


>On 2013-05-31, at 19:18 , Philipp A. wrote:


>> (yaml
>> afaik knows all of those, albeit with different syntax than python. but it
>> has them, allowing to easily represent more of python’s capabilities)
>
>YAML has no rawstrings that I know of. 

Single-quoted strings are basically raw strings. They're different from raw strings in the same way all YAML strings are different from Python strings—newlines and doubling the quotes to escape them—but they ignore escape sequences, which is the fundamental property of raw strings.

See http://www.yaml.org/spec/1.2/spec.html#id2760844 for an example, and section 7.3.2 for specifics.

>It also has no byte literals, there
>is a working draft for a binary tag encoded in base64[0]. 

Section 10.4 explicitly says that "It is strongly recommended that [interoperable] schemas make as much use as possible of the the YAML tag repository at http://yaml.org/type/. This repository provides recommended global tags for increasing the portability of YAML documents between different applications." 

Even though most of the tags in the repository are officially working drafts, they're effectively standards.


>Its failsafe

>schema only contains strings (unicode), same as JSON.

But the spec doesn't recommend using the failsafe schema for most purposes. Section 10.3 says "[The core schema] is the recommended default schema that YAML processor should use unless instructed otherwise. It is also strongly recommended that other schemas should be based on it."

Section 10.4 then implies that what most applications really should be using is something the spec doesn't quite name or define—the core schema plus all the tags from the repository.

Note that all of this means you can't just say "use YAML" to specify anything; you have to say "use this YAML schema". So, if we were to follow the OP's suggestion of using YAML for metadata, it would have to be more specific than that.


More information about the Python-ideas mailing list