PEP 822 proposes a new 'd-string' (dented multi-line string) syntax for Python, likely targeting version 3.15. Currently a draft, it introduces a 'd' prefix before triple-quoted strings that automatically strips common leading whitespace — essentially syntax sugar for `textwrap.dedent()`. The feature solves the awkward indentation problem when writing multi-line strings inside indented code blocks. D-strings can be combined with other string prefixes like f-strings (df""") or raw strings (dr"""). The PEP also documents rejected alternatives such as markdown-style backtick literals, new quote characters, and Swift-style trailing newline trimming.
•6m watch time
8 Comments
Sort: