forcing pyYAML to dump consistently

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 of above two dumps different? Is it possible to force pyYAML to split the list always?


From the documentation:

print yaml.dump(a, default_flow_style=False)

The value can be True, False, or None. If None or unspecified (that is, the default), it chooses automatically whether to use inline or block-style output. False never uses inline, True is always inline.

Need Your Help

How to remove multiple rows from TreeView in GTK#

c# mono gtk gtk#

Removing multiple rows from a TreeView in mono GTK# has tripped me up a little bit lately and the answer wasn't a quick google search away so I'm posting this question here. It has been extra probl...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.