In my yam file I am trying this
with open(fname, "w") as f:
yaml.safe_dump({'items':['test', 'test2']}, f,
default_flow_style=False, width=50, indent=4)
It prints in the below format
items:
- 'test'
- 'test2'
I want the output formatted like below
items: ['test', 'test2']
How can I do that ?
EDIT:
This is my complete code
d = {}
for m in ['B1', 'B2', 'B3']:
d2 = {}
for f in ['A1', 'A2', 'A3']:
# here i don't want any flow style
d2[f] = ['test', 'test2']
d[m] = d2
with open(fname, "w") as f:
yaml.safe_dump(d, f, default_flow_style=True, width=50, indent=8)