I’m writing a YAML file which contains some configuration data. It will be read in to Python as a dictionary of dictionaries. Some of the data needs to be repeated under a different key. Is there a way to do this without large amounts of cut and paste?
Here is an example of the yaml file:
BLOCK1:
a: 1
b: 2
c: 3
BLOCK2:
a: 4
b: 5
c: 6
BLOCK3: # Basically the same as BLOCK2
a: 4 # Is there a way to make this a link to BLOCK2 or a copy of BLOCK2?
b: 5
c: 6
Yes, there is. Take a look at: http://pyyaml.org/wiki/PyYAMLDocumentation#Aliases
Basically, you should do:
And the results will be: