Author jtojnar
Recipients Marco Sulla, Miguel Amaral, gregory.p.smith, josh.r, jtojnar, mbussonn, methane, pablogsal, remi.lapeyre, rhettinger, serhiy.storchaka, steven.daprano, terry.reedy
Date 2020-12-03.22:44:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1607035472.12.0.717943352634.issue36906@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-12-03 22:44:32jtojnarsetrecipients: + jtojnar, rhettinger, terry.reedy, gregory.p.smith, steven.daprano, methane, serhiy.storchaka, josh.r, mbussonn, pablogsal, remi.lapeyre, Marco Sulla, Miguel Amaral
2020-12-03 22:44:32jtojnarsetmessageid: <1607035472.12.0.717943352634.issue36906@roundup.psfhosted.org>
2020-12-03 22:44:32jtojnarlinkissue36906 messages
2020-12-03 22:44:31jtojnarcreate