This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gregory.p.smith
Recipients gregory.p.smith
Date 2019-05-13.18:40:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1557772831.22.0.440689390024.issue36906@roundup.psfhosted.org>
In-reply-to
Content
A Python pattern in code is to keep everything indented to look pretty while, yet when the triple quoted multiline string in question needs to not have leading whitespace, calling textwrap.dedent("""long multiline constant""") is a common pattern.

rather than doing this computation at runtime, this is something that'd make sense to do at compilation time.  A natural suggestion for this would be a new letter prefix for multiline string literals that triggers this.

Probably not worth "wasting" a letter on this, so I'll understand if we reject the idea, but it'd be nice to have rather than importing textwrap and calling it all over the place just for this purpose.

There are many workarounds but an actual syntax would enable writing code that looked like this:

```python
class Castle:
    def __init__(self, name, lyrics=None):
        if not lyrics:
            lyrics = df"""\
            We're knights of the round table
            We dance whene'er we're able
            We do routines and scenes
            With footwork impeccable.
            We dine well here in {name}
            We eat ham and jam and spam a lot.
            """
        self._name = name
        self._lyrics = lyrics
```

Without generating a larger temporary always in memory string literal in the code object that gets converted at runtime to the desired dedented form via a textwrap.dedent() call.  I chose "d" as the the letter to mean dedent.  I don't have a strong preference if we ever do make this a feature.
History
Date User Action Args
2019-05-13 18:40:31gregory.p.smithsetrecipients: + gregory.p.smith
2019-05-13 18:40:31gregory.p.smithsetmessageid: <1557772831.22.0.440689390024.issue36906@roundup.psfhosted.org>
2019-05-13 18:40:31gregory.p.smithlinkissue36906 messages
2019-05-13 18:40:30gregory.p.smithcreate