Multiline strings are ugly after dumping
See original GitHub issue>>> lines = """
... a
... b
... c
... """
>>> lines
'\na\nb\nc\n'
>>> print(yaml.dump({'a': lines}, default_flow_style=False))
a: '
a
b
c
'
>>> # although roundtrip of dump-load is correct
>>> yaml.load(yaml.dump({'a': lines}))
{'a': '\na\nb\nc\n'}
This could output much shorter
a: |
a
b
c
Issue Analytics
- State:
- Created 5 years ago
- Reactions:22
- Comments:12 (4 by maintainers)
Top Results From Across the Web
ValueError compatibility and multi-line string aesthetics?
You can even make your own ValueError subclass that represents itself by dumping the long string. You can even throw the textwrap stuff...
Read more >Multiline string literals: can we get rid of the need for ...
I.e. The rule would be that a single quote at the end of a line starts a multi-line string literal. The string is...
Read more >my girlfriend is getting uglier and uglier to me by the day
I know the automatic response is 'dump her' but she's really fragile and 'sweet' she cries easily and I know how much I...
Read more >Strings in YAML - To Quote or not to Quote | tinita [blogs.perl.org]
If you look at JSON, you have only one style to encode strings, and that's the double quoted style which doesn't allow literal...
Read more >If an ex starts talking to girls, right after you break up ... - Quora
Why is it good not to get in a relationship right away after a long term break up? You replace your ex with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
found this on StackOverflow as a quick fix for my requirement:
Slight tweak, better handles strings ending in a newline and might be a bit faster: