Closed
Description
Weird bug that I'm trying to sort out. A small demonstration:
>>> items = [f"{k:02d}" for k in range(1, 12)]
>>> print(items)
['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11']
>>> print(yaml.dump(items)
- '01'
- '02'
- '03'
- '04'
- '05'
- '06'
- '07'
- 08
- 09
- '10'
- '11'
This occurs
- when specifying
dump(items, Dumper=yaml.Dumper)
anddump(items, Dumper=yaml.CDumper)
. - seemingly for strings beginning with 0 and ending in 8 or 9.
>>> fmts = ["{:0%id}"%k for k in range(1, 6)]
>>> print(yaml.dump([f.format(7) for f in fmts]))
- '7'
- '07'
- '007'
- '0007'
- '00007'
>>> print(yaml.dump([f.format(9) for f in fmts]))
- '9'
- 09
- 009
- 0009
- 00009
>>> print(yaml.dump([f"{k}09" for k in range(10)]))
- 009
- '109'
- '209'
- '309'
- '409'
- '509'
- '609'
- '709'
- '809'
- '909'
While adding default_style="'"
to the dump helps resolve these values, it adds that styling to everything which is not desired.
Any suggestions?
Metadata
Metadata
Assignees
Labels
No labels