Message382456
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. |
|
Date |
User |
Action |
Args |
2020-12-03 22:44:32 | jtojnar | set | recipients:
+ 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:32 | jtojnar | set | messageid: <1607035472.12.0.717943352634.issue36906@roundup.psfhosted.org> |
2020-12-03 22:44:32 | jtojnar | link | issue36906 messages |
2020-12-03 22:44:31 | jtojnar | create | |
|