[Python-ideas] Dart like multi line strings identation

Robert Vanden Eynde robertve92 at gmail.com
Sat Mar 31 11:48:06 EDT 2018


So yes, currently you just do :

import textwrap

print(textwrap.dedent("""
    I am
    A Line
"""))

So you'd want a string litteral ?

print(d"""
    I am
    A Line
""")

Le sam. 31 mars 2018 à 17:06, Ryan Gonzalez <rymg19 at gmail.com> a écrit :

> I have to admit, regardless of how practical this is, it would surely get
> rid of a ton of textwrap.dedent calls all over the place...
>
> On March 31, 2018 9:50:43 AM Marius Räsener <m.raesener at gmail.com> wrote:
>
>> Hey List,
>>
>> this is my very first approach to suggest a Python improvement I'd think
>> worth discussing.
>>
>> At some point, maybe with Dart 2.0 or a little earlier, Dart is now
>> supporting multiline strings with "proper" identation (tried, but I can't
>> find the according docs at the moment. probably due to the rather large
>> changes related to dart 2.0 and outdated docs.)
>>
>> What I have in mind is probably best described with an Example:
>>
>> print("""
>>     I am a
>>     multiline
>>     String.
>>     """)
>>
>> the closing quote defines the "margin indentation" - so in this example
>> all lines would get reduces by their leading 4 spaces, resulting in a
>> "clean" and unintended string.
>>
>> anyways, if dart or not, doesn't matter - I like the Idea and I think
>> python3.x could benefit from it. If that's possible at all :)
>>
>> I could also imagine that this "indentation cleanup" only is applied if
>> the last quotes are on their own line? Might be too complicated though, I
>> can't estimated or understand this...
>>
>> thx for reading,
>> Marius
>>
>> _______________________________________________
>> Python-ideas mailing list
>> Python-ideas at python.org
>> https://mail.python.org/mailman/listinfo/python-ideas
>> Code of Conduct: http://python.org/psf/codeofconduct/
>>
>>
> --
> Ryan (ライアン)
> Yoko Shimomura, ryo (supercell/EGOIST), Hiroyuki Sawano >> everyone else
> https://refi64.com/
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180331/2372a00c/attachment.html>


More information about the Python-ideas mailing list