A "d" prefix to do textwrap.dedent is something I wished for a long time.
It's like the "f" one: we already can do it, be hell is it convenient to have a shortcut. This is especially if, like me, you take a lot of care in the error messages you give to the user. I write a LOT of them, very long, very descriptive, and I have to either import textwrap or play the concatenation game. Having a str.dedent() method would be nice, but the d prefix has the huge advantage to be able to dedent on parsing, and hence be more performant. Le 31/03/2018 à 16:50, Marius Räsener a écrit : > 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@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/