Jan Tojnar <jtoj...@gmail.com> added the comment:
One benefit of using a compile time feature over a runtime method is that the former allows for more predictable dedenting by first dedenting and only then interpolating variables. For example, the following code does not dedent the test string at all: ```python import textwrap foo = "\n".join(["aaa", "bbb"]) test = textwrap.dedent( f""" block xxx: {foo} """ ) ``` It would be much nicer if we had syntactical dedents based on the leftmost non-whitespace column in the string, as supported by Nix language, for example. ```python test = ( df""" block xxx: {textwrap.indent(foo, ' '*4)} """ ) ``` It would be even nicer if the interpolated strings could be indented based on the column the interpolation occurs in but that can at least be done at runtime with only minor inconvenience. ---------- nosy: +jtojnar _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36906> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com