[Python-ideas] Multi-line string indentation
Chris Angelico
rosuav at gmail.com
Fri Feb 8 11:28:14 EST 2019
On Sat, Feb 9, 2019 at 3:19 AM Paul Moore <p.f.moore at gmail.com> wrote:
>
> On Thu, 7 Feb 2019 at 18:21, Mike Miller <python-ideas at mgmiller.net> wrote:
> > Anyone still interested in this?
>
> It feels like a nice idea to me, when reading the proposals. However,
> in all of the code I've ever written in Python (and that's quite a
> lot...) I've never actually had a case where I this feature would have
> made a significant difference to the code I wrote. Maybe that says
> more about my coding style than about the usefulness of the feature,
> but personally I don't think it's worth it.
>
> Paul
>
> PS Although I could probably have said something similar about
> f-strings, and now I use them all the time. Language design is hard
> ;-)
Yeah, no kidding :-)
If someone wants to push this further, I'm happy to assist with the
mechanics of writing up a PEP. From my memory, the leading proposals
were:
1) Creating a new type of string literal which compiles to a dedented
form of multiline string
2a) Adding a str.dedent() method
2b) Creating a constant-folding peephole optimization for methods on
immutable literals
Either way, the definition of "dedent" would be identical to
textwrap.dedent(), meaning that if 2a were to happen, that function
could simply "return text.dedent()".
Who wants to champion this proposal?
ChrisA
More information about the Python-ideas
mailing list