Pre-PEP: d-string / Dedented Multiline Strings with Optional Language Hinting

str.dedent() cannot dedent t-string and f-string in compile time.
Additionally, str.dedent is difficult to produce string having some indent:

html_parts = """\
      <div>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sed efficitur ante.
      </div>
    END""".dedent().removesuffix("END")

Other examples that str.dedent() cannot solve in previous thread:

4 Likes