YAML key consisting of a list of elements
<p>I need to have a list of elements as a key, so that I can check if several conditions are met. 
Example (don't know if this is possible and if the syntax is correct):</p>

<pre><code>mapping:
  c_id:
    [pak, gb]: '4711'
    [pak, ch]: '4712'
    [pak]: '4713'
  d_id:
    .
    .
    .
</code></pre>

<p>Now I need to know if it is possible to have an approach as in the example.</p>

<p>In addition to Anthon's answer, here is how you can do it with PyYaml:</p>

<pre><code>mapping:
  c_id:
    !!python/tuple [pak, gb]: '4711'
    !!python/tuple [pak, ch]: '4712'
    !!python/tuple [pak]: '4713'
</code></pre>

<p>The trick is to tell PyYaml that you want to load the keys into a tuple (since a list cannot be used as dict key). There is no way to do this <em>implicitly</em>, but this does not mean that it is not possible.</p>

<p>Explicit keys may be more readable in this case:</p>

<pre><code>mapping:
  c_id:
    ? !!python/tuple [pak, gb]
    : '4711'
    ? !!python/tuple [pak, ch]
    : '4712'
    ? !!python/tuple [pak]
    : '4713'
</code></pre>

<p>This example is semantically equivalent to the first one.</p>

python yaml pyyaml