python yaml.dump format list in other YAML format -
i want dump python object yaml file this:
a: 5 b: 6 c: 7 d: [ 1,2,3,4]
but not
a: 5 b: 6 c: 7 d - 1 - 2 - 3 - 4
image d massive list, output gets messy humans see.
i use: default_flow_style=false
uses new line list item format.
i use customer dumper stop anchors.
is following result meeting expectations?
>>> import yaml >>> dct = {"a": 5, "b": 6, "c": 7, "d": range(60)} >>> print yaml.dump(dct) a: 5 b: 6 c: 7 d: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]
note, linebreaks added yaml
, not me.
Comments
Post a Comment