Python was one of first programming languages that added support of triple-quoted string literals. Since then, the support of them has been added in many other programming languages, both new (like Julia) and old (like Java). Where they were added later, usage patterns and issues were taken into account. It would be good if Python borrowed this experience.
I would like to change the interpretation of triple-quoted strings by default (after long period of adaptation, with corresponding __future__ import). But if it is not possible, adding a new ādā prefix is the second good option.
Advantages of automatic dedenting triple-quoted string literals:
- It applies before interpreting special sequences, so it is easy to disable dedenting, control the depth of dedenting or add leading or trailing newlines that should not be stripped. The
str.dedent()method does not have access to original representation. - It can be used with docstrings. It will make docstrings more readable by default, without preprocessing in pydoc.
- It can be used with f-strings. It will dedent the original template, not the resulting string after substitution.
https://docs.julialang.org/en/v1/manual/strings/#Triple-Quoted-String-Literals
https://openjdk.org/jeps/378