Force pyYAML rollup

In [136]: a = [1,2,3,4,5] In [137]: print yaml.dump(a) [1, 2, 3, 4, 5] In [138]: a = [1,2,3,4,5, [1,2,3]] In [139]: print yaml.dump(a) - 1 - 2 - 3 - 4 - 5 - [1, 2, 3] 

why are the outputs above two dumps different? Is it possible to force pyYAML split list always?

+6
source share
1 answer

From the documentation :

 print yaml.dump(a, default_flow_style=False) 

The value can be True , False or None . If None or undefined (i.e. by default), it automatically chooses whether to use inline or block output. False never uses inline, True always in line.

+8
source

All Articles