[Python-ideas] Idea for new multi-line triple quote literal

Philipp A. flying-sheep at web.de
Mon Jul 1 18:22:25 CEST 2013


2013/7/1 Guido van Rossum guido at python.org

That‘s a compelling argument. Let’s do it. (Assuming the definition of
exactly how to indent or dedent is not up for discussion — if there
are good reasons to disagree with textwrap now's the time to bring it
up.)

I don’t know if it’s a good reason, but I’m of the opinion that the
required backslash at the beginning of to-be-dedented string is strange:

We try to eliminate escaped newlines elsewhere (e.g. bracing import
statements, conditions and tuple values is preferred to escaping newlines)

I think dedent (or however it’s going to be called) should remove common
whitespace and, if the first line is completely empty, that first line as
well.

Also for your consideration would be scala’s way:

"""|spam
   |eggs""".stripMargin() == "spam\neggs"
"""#spam
   #eggs""".stripMargin('#') == "spam\neggs"

i.e. removal of all leading whitespace up to and including a margin
character/prefix. It could be a kwarg to “dedent”…
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130701/76a55127/attachment.html>


More information about the Python-ideas mailing list