Thanks for all of your replies. I did not know about the dedent() function. I will use it for now on. If anyone else desires to push this, feel free, but I am satisfied.
Daniel da Silva wrote:[...]
On several occasions I have run into code that will do something like the
following with a multiline string:
Please no. Three quotes is large enough. Also, four quotes currently is legal: it is a triple-quoted string that begins with a quotation mark. You would be changing that behaviour and likely breaking code.
To me, this is rather ugly because it messes up the indentation of
some_func(). Suppose we could have a multiline string, that when started on
a line indented four spaces, ignores the first four spaces on each line of
the literal when creating the actual string?
In this example, I will use four quotes to start such a string.
I don't think we need syntax for this, but if we do, I'd prefer to add a prefix similar to the r"" or u"" syntax. Perhaps w"" to normalise whitespace?
But as I said, I don't think we need syntax for this. I'd be happy if textwrap.dedent() became a built-in string method.""".dedent() % (x, y)
x, y = process_something()
val = """
Python-ideas mailing list