5 ms·
How do you propose handling the most common case, when I don't want leading indentations? String s1 = """<outer> <inner>foo</inner> </outer>"""
by vbezhenar 7y ago
How do you propose handling the most common case, when I don't want leading indentations?
String s1 = """<outer>
<inner>foo</inner>
</outer>""";
is ugly.
- kevingadd 7y agoIt's how C# does it. You can always put in a leading newline and strip it via an API call, or put the """ at the start of the next line.
- dfinninger 7y agoPython has the textwrap[1] module in the standard library. Calling “textwrap.dedent()” on the docstring (multiline string) will strip white space to the least-indented line inside the text. I’m personally a fan of having an easily-accessible method to call. That way you get indented text blocks and no “magic” formatting (at least, you explicitly opt-in to the magic formatting). [1] https://docs.python.org/3/library/textwrap.html https://docs.python.org/3/library/textwrap.html
- etaty 7y agoScala use stripmargin (default "|") https://docs.scala-lang.org/overviews/scala-book/two-notes-about-strings.html https://docs.scala-lang.org/overviews/scala-book/two-notes-a...