On Tue, Mar 26, 2019 at 2:02 PM Chris Angelico <ros...@gmail.com> wrote: > > On Tue, Mar 26, 2019 at 9:49 PM Mikhail V <mikhail...@gmail.com> wrote: > > Procedural removal is not cool, because it does not know the parent > > indentation > > [...] > > E.g. this: > > s = """ > > Hello > > world""" > > > > Here I do not want to remove all indents but only as in above - only 1 > > level inside string > > and 1 from parent line. > > This is true if you put your closing quotes on the same line as the > last line of text, because then there's no information available. If, > instead, you put the final triple-quote delimiter on its own line, you > then have the indentation preserved, and can remove just that much > indentation from each line. So, yes, you CAN unindent automatically. > > Point of note: PEP 257 recommends this for docstrings. > > https://www.python.org/dev/peps/pep-0257/#handling-docstring-indentation > > ChrisA
Yes you are right. If closing triple quote is on a separate line , I can use the last line contents and extract it from previous lines. I should have remembered that trick and it is cool actually. So technically I can do it. So my point was that it would be cool to have a dedicated statement for this and so it works on parser level plus would look cleaner (no closing quotes), and no need to care about escaping of """ sequence if it appears inside the string, but I think that would be impossible without the parser knowing the indent method in advance. _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/