Hello devs,
I need to record a scene hierarchy to a YAML file and then replicate it in the exact order in Maya. The real data is more complex tree and iteration is recursive function, but this is simplified version:
import yaml
dictionary = {
"PARENT": {"B": {}, "A": {}, "C": {}, "D": {}}
}
data = yaml.safe_load(yaml.dump(dictionary))
for key_parent, value_parent in data.iteritems():
for key_child, value_child in value_parent.iteritems():
print key_child
The result is A C B D. Why I am not getting B A C D? Is there a way to control this?
Also, if I print yaml.dump(dictionary)
I will get:
PARENT:
A: {}
B: {}
C: {}
D: {}
which looks like an alphabetically sorted source dictionary. Why during iteration I don’t get sorted output?