I'm currently a little bit confused by PyYAML. I installed version 3.12 on my Windows and my Linux system and have seen, that it behaves differently in sorting the values.
Lets have a look at this example YAML-file:
functions:
function_a:
value_1: 1
value_2: 1
value_3: 1
function_c:
value_1: 1
value_2: 1
value_3: 1
function_d:
value_1: 1
value_2: 1
value_4: 1
function_b:
value_1: 1
value_2: 1
value_3: 1
Loading the YAML file is done like usual via conf = yaml.load(fp)
.
Now, what's really strange between those two systems is, that when I try to go through all functions, I get a different order on both OS systems.
On Windows it would be:
import yaml
with open('myyamlfile.yml') as fp:
conf = yaml.load(fp)
for function in conf['functions']:
print(function)
function_a
function_c
function_d
function_b
On Linux it comes in an ordered way:
import yaml
with open('myyamlfile.yml') as fp:
conf = yaml.load(fp)
for function in conf['functions']:
print(function)
function_a
function_b
function_c
function_d
And I really do not have any clue why. I'm using the same code on both machines with the same module version. The only difference between both machines is the OS and the fact, that on Windows I'm using 3.6.5 and on Linux I'm using 3.4.8.
Has anyone a hint for me why this happens?